Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1207253

Summary: "git submodule add -f URL PATH" doesn't work despite git suggests it
Product: Red Hat Enterprise Linux 6 Reporter: Jan Pokorný [poki] <jpokorny>
Component: gitAssignee: Petr Stodulka <pstodulk>
Status: CLOSED ERRATA QA Contact: Andrej Dzilský <adzilsky>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.7CC: adzilsky, psklenar, thozza
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: git-1.7.1-8.el6 Doc Type: No Doc Update
Doc Text:
undefined
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-21 10:00:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1254457, 1355829, 1359264    
Attachments:
Description Flags
Patch none

Description Jan Pokorný [poki] 2015-03-30 14:02:50 UTC
Demo of the issue:

$ pushd /tmp
> /tmp
$ git clone https://github.com/richardfontana/copyleft-next.git
> Initialized empty Git repository in /tmp/copyleft-next/.git/
> remote: Counting objects: 2306, done.
> remote: Total 2306 (delta 0), reused 0 (delta 0), pack-reused 2306
> Receiving objects: 100% (2306/2306), 508.83 KiB | 606 KiB/s, done.
> Resolving deltas: 100% (1127/1127), done.
$ cd copyleft-next
$ echo "/example-project" > .gitignore
$ git submodule add -- https://github.com/creativecommons/example-project.git example-project
> Initialized empty Git repository in /tmp/copyleft-next/example-project/.git/
> remote: Counting objects: 13, done.
> remote: Total 13 (delta 0), reused 0 (delta 0), pack-reused 13
> Unpacking objects: 100% (13/13), done.
> The following paths are ignored by one of your .gitignore files:
> example-project
> Use -f if you really want to add them.
> fatal: no files added
> Failed to add submodule 'example-project'

(Ok, will use -f as I "really want to add them")

$ git submodule add -f -- https://github.com/creativecommons/example-project.git example-project
> Usage: git submodule [--quiet] add [-b branch] [--reference <repository>] [--] <repository> [<path>]
>    or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
>    or: git submodule [--quiet] init [--] [<path>...]
>    or: git submodule [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
>    or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
>    or: git submodule [--quiet] foreach [--recursive] <command>
>    or: git submodule [--quiet] sync [--] [<path>...]

Ouch.  This works nicely with newer versions of git, though.

$ rpm -q git
git-1.7.1-3.el6_4.1.x86_64

Comment 2 Petr Stodulka 2015-03-30 20:55:04 UTC
Created attachment 1008666 [details]
Patch

Upstream patch. Force option missed in git-submodules.sh

Comment 6 Petr Stodulka 2016-12-07 23:38:38 UTC
Moved back to assigned because of found bug by Martin Cermak (#1401872). We overlooked that option --ignore-missing for "add" subcommand doesn't exist in git v1.7.1 so import of new submodules were not possible without --force option.

Correct solution without futile clone of the module when it can't be imported
is bigger for implementation (upstream creates more fixes because of this option) - and probably time consuming for correct testing, proposed solution removes problematic check (without this --ignore-missing option, we can't do that reasonably).

So when user doesn't use -f or --force option and file is on a .gitignore list, user will see erro message as above to use -f option, but module will be already downloaded in the repo.

With -f or --force option a modul will be correctly added in that case.
(Hope that my explanation is clear.)

Comment 8 Andrej Dzilský 2016-12-14 16:31:54 UTC
Current solution works as intented.

Comment 10 errata-xmlrpc 2017-03-21 10:00:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2017-0640.html