<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/git-submodule.sh, branch v2.32.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.32.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.32.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2021-05-03T03:24:38Z</updated>
<entry>
<title>submodule update: silence underlying fetch with "--quiet"</title>
<updated>2021-05-03T03:24:38Z</updated>
<author>
<name>Nicholas Clark</name>
<email>nick@ccl4.org</email>
</author>
<published>2021-04-30T09:59:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=62af4bdd423f5f3988dad97abcdd7adfba0756c4'/>
<id>urn:sha1:62af4bdd423f5f3988dad97abcdd7adfba0756c4</id>
<content type='text'>
Commands such as

    $ git submodule update --quiet --init --depth=1

involving shallow clones, call the shell function fetch_in_submodule, which
in turn invokes git fetch.  Pass the --quiet option onward there.

Signed-off-by: Nicholas Clark &lt;nick@ccl4.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>submodule: fix fetch_in_submodule logic</title>
<updated>2020-11-24T21:14:09Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2020-11-24T09:06:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=66d36b94af6351d1e9b68a871d5faeb8a27d8a33'/>
<id>urn:sha1:66d36b94af6351d1e9b68a871d5faeb8a27d8a33</id>
<content type='text'>
Commit 1c1518071c (submodule: use "fetch" logic instead of custom remote
discovery, 2020-11-14) rewrote the logic in fetch_in_submodule to do:

  elif test "$2" -ne ""

But this is nonsense in shell: -ne is for numeric comparisons. This
should be "=" or more idiomatically:

  elif test -n "$2"

But once we fix that, many tests start failing. Because that commit
introduced another problem. The caller that passes 3 arguments looks
like this:

    fetch_in_submodule "$sm_path" $depth "$sha1"

Note the unquoted $depth parameter. When it isn't set, the function will
see only 2 arguments, and the function has no idea if what it sees in $2
is an option to go on the command line, or a refspec to pass on stdin.
In the old code before that commit:

   fetch_in_submodule () (
        sanitize_submodule_env &amp;&amp;
        cd "$1" &amp;&amp;
  -     case "$2" in
  -     '')
  -             git fetch ;;
  -     *)
  -             shift
  -             git fetch $(get_default_remote) "$@" ;;
  -     esac

we treated those the same, so it didn't matter. But in the new logic
(with my fix above):

  +     if test $# -eq 3
  +     then
  +             echo "$3" | git fetch --stdin "$2"
  +     elif test -n "$n"
  +     then
  +             git fetch "$2"
  +     else
  +             git fetch
  +     fi

we use the number of parameters to distinguish the two. Let's insist
that the caller pass an empty string for positional parameter two if
they want to have a third parameter after it.

But that still leaves one problem. In the --stdin block, we
unconditionally pass "$2" to git-fetch, even if it's the empty string.
Rather than add another conditional, we can use :+ parameter expansion
to include it only if it's non-empty. In fact, we can do the same for
the elif, too, simplifying it further. Technically this is overkill,
since we know the --depth parameter will not have whitespace (and
indeed, most callers do not bother quoting it), but it doesn't hurt for
the function to be careful.

It's somewhat amazing that no tests were failing. I think what happened
is that:

  - the 3-arg form rarely triggered; any call with a non-empty $depth
    and a $sha1 would work, but one with an empty $depth would only have
    2 arguments

  - because of the wrong arguments to "test", the shell would complain
    and exit non-zero. So we never ran the middle conditional at all

  - that left every call running "git fetch" with no arguments. A
    well-written test could have detected the distinction here, but in
    practice omitting --depth just means fetching more commits, and
    fetching everything (rather than a single sha1) works as long as the
    commit in question is reachable

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>parse-remote: remove this now-unused library</title>
<updated>2020-11-16T21:19:30Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2020-11-14T12:21:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a89a2fbfccd88bc8a3c8cce8d7bc03de3830ea25'/>
<id>urn:sha1:a89a2fbfccd88bc8a3c8cce8d7bc03de3830ea25</id>
<content type='text'>
The previous two commits removed the last use of a function in this
library, but most of it had been dead code for a while[1][2]. Only the
"get_default_remote" function was still being used.

Even though we had a manual page for this library it was never
intended (or I expect, actually) used outside of git.git. Let's just
remove it, if anyone still cares about a function here they can pull
them into their own project[3].

1. Last use of error_on_missing_default_upstream():
   d03ebd411c ("rebase: remove the rebase.useBuiltin setting",
   2019-03-18)

2. Last use of get_remote_merge_branch(): 49eb8d39c7 ("Remove
   contrib/examples/*", 2018-03-25)

3. https://lore.kernel.org/git/87a6vmhdka.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>submodule: remove sh function in favor of helper</title>
<updated>2020-11-16T21:15:00Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2020-11-14T12:21:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e63f7b0acba326a47282036afffb83e2b3eb023d'/>
<id>urn:sha1:e63f7b0acba326a47282036afffb83e2b3eb023d</id>
<content type='text'>
Remove the now-redundant "get_default_remote" function by converting
its last user to the "print-default-remote" helper.

As can be seen in 13424764db ("submodule: port submodule subcommand
'sync' from shell to C", 2018-01-15) this helper is already used
internally by the C code for submodule remote name discovery.

The "get_default_remote" function in "git-parse-remote.sh" will be
removed in a follow-up change.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>submodule: use "fetch" logic instead of custom remote discovery</title>
<updated>2020-11-16T20:54:43Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2020-11-14T12:21:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1c1518071c7fa79de13b8c599d8dbb371950b033'/>
<id>urn:sha1:1c1518071c7fa79de13b8c599d8dbb371950b033</id>
<content type='text'>
Replace a use of the get_default_remote() function with an invocation
of "git fetch"

The "fetch" command already has logic to discover the remote for the
current branch. However, before it learned to accept a custom
refspec *and* use its idea of the default remote, it wasn't possible
to get rid of some equivalent of the "get_default_remote" invocation
here.

As it turns out the recently added "--stdin" option to fetch[1] gives
us a way to do that. Let's use it instead.

While I'm at it simplify the "fetch_in_submodule" function. It wasn't
necessary to pass "$@" to "fetch" since we'd only ever provide one
SHA-1 as an argument in the previous "*" codepath (in addition to
"--depth=N"). Rewrite the function to more narrowly reflect its
use-case.

1. https://lore.kernel.org/git/87eekwf87n.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'td/submodule-update-quiet'</title>
<updated>2020-10-05T21:01:53Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-10-05T21:01:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=300cd14ee92eaa0e56688078e967402371488013'/>
<id>urn:sha1:300cd14ee92eaa0e56688078e967402371488013</id>
<content type='text'>
"git submodule update --quiet" did not squelch underlying "rebase"
and "pull" commands.

* td/submodule-update-quiet:
  submodule update: silence underlying merge/rebase with "--quiet"
</content>
</entry>
<entry>
<title>submodule update: silence underlying merge/rebase with "--quiet"</title>
<updated>2020-10-01T15:50:24Z</updated>
<author>
<name>Theodore Dubois</name>
<email>tbodt@google.com</email>
</author>
<published>2020-09-30T19:50:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3ad0401e9e6d3e243a21a3f376e36453572dcf0d'/>
<id>urn:sha1:3ad0401e9e6d3e243a21a3f376e36453572dcf0d</id>
<content type='text'>
Commands such as

    $ git pull --rebase --recurse-submodules --quiet

produce non-quiet output from the merge or rebase.  Pass the --quiet
option down when invoking "rebase" and "merge".

Also fix the parsing of git submodule update -v.

When e84c3cf3 (git-submodule.sh: accept verbose flag in cmd_update
to be non-quiet, 2018-08-14) taught "git submodule update" to take
"--quiet", it apparently did not know how ${GIT_QUIET:+--quiet}
works, and reviewers seem to have missed that setting the variable
to "0", rather than unsetting it, still results in "--quiet" being
passed to underlying commands.

Signed-off-by: Theodore Dubois &lt;tbodt@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>submodule: port submodule subcommand 'summary' from shell to C</title>
<updated>2020-08-12T21:12:58Z</updated>
<author>
<name>Prathamesh Chavan</name>
<email>pc44800@gmail.com</email>
</author>
<published>2020-08-12T19:44:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e83e3333b5770815e9c2e3aee48c305257385bbb'/>
<id>urn:sha1:e83e3333b5770815e9c2e3aee48c305257385bbb</id>
<content type='text'>
Convert submodule subcommand 'summary' to a builtin and call it via
'git-submodule.sh'.

The shell version had to call $diff_cmd twice, once to find the modified
modules cared by the user and then again, with that list of modules
to do various operations for computing the summary of those modules.
On the other hand, the C version does not need a second call to
$diff_cmd since it reuses the module list from the first call to do the
aforementioned tasks.

In the C version, we use the combination of setting a child process'
working directory to the submodule path and then calling
'prepare_submodule_repo_env()' which also sets the 'GIT_DIR' to '.git',
so that we can be certain that those spawned processes will not access
the superproject's ODB by mistake.

A behavioural difference between the C and the shell version is that the
shell version outputs two line feeds after the 'git log' output when run
outside of the tests while the C version outputs one line feed in any
case. The reason for this is that the shell version calls log with
'--pretty=format:&lt;fmt&gt;' whose output is followed by two echo
calls; 'format' does not have "terminator" semantics like its 'tformat'
counterpart. So, the log output is terminated by a newline only when
invoked by the user and not when invoked from the scripts. This results
in the one &amp; two line feed differences in the shell version.
On the other hand, the C version calls log with '--pretty=&lt;fmt&gt;'
which is equivalent to '--pretty:tformat:&lt;fmt&gt;' which is then
followed by a 'printf("\n")'. Due to its "terminator" semantics the
log output is always terminated by newline and hence one line feed in
any case.

Also, when we try to pass an option-like argument after a non-option
argument, for instance:

    git submodule summary HEAD --foo-bar

    (or)

    git submodule summary HEAD --cached

That argument would be treated like a path to the submodule for which
the user is requesting a summary. So, the option ends up having no
effect. Though, passing '--quiet' is an exception to this:

    git submodule summary HEAD --quiet

While 'summary' doesn't support '--quiet', we don't get an output for
the above command as '--quiet' is treated as a path which means we get
an output only if a submodule whose path is '--quiet' exists.

The error message in case of computing a summary for non-existent
submodules in the C version is different from that of the shell version.
Since the new error message is not marked for translation, change the
'test_i18ngrep' in t7421.4 to 'grep'.

Mentored-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Mentored-by: Stefan Beller &lt;stefanbeller@gmail.com&gt;
Mentored-by: Kaartic Sivaraam &lt;kaartic.sivaraam@gmail.com&gt;
Helped-by: Johannes Schindelin &lt;Johannes.Schindelin@gmx.de&gt;
Signed-off-by: Prathamesh Chavan &lt;pc44800@gmail.com&gt;
Signed-off-by: Shourya Shukla &lt;shouryashukla.oo@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>submodule: port subcommand 'set-branch' from shell to C</title>
<updated>2020-06-02T17:51:54Z</updated>
<author>
<name>Shourya Shukla</name>
<email>shouryashukla.oo@gmail.com</email>
</author>
<published>2020-06-02T16:35:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2964d6e5e1e5e3286cfdc8c68f347e0aba97caf0'/>
<id>urn:sha1:2964d6e5e1e5e3286cfdc8c68f347e0aba97caf0</id>
<content type='text'>
Convert submodule subcommand 'set-branch' to a builtin and call it via
'git-submodule.sh'.

Mentored-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Mentored-by: Kaartic Sivaraam &lt;kaartic.sivaraam@gmail.com&gt;
Helped-by: Denton Liu &lt;liu.denton@gmail.com&gt;
Helped-by: Eric Sunshine &lt;sunshine@sunshineco.com&gt;
Helped-by: Đoàn Trần Công Danh &lt;congdanhqx@gmail.com&gt;
Signed-off-by: Shourya Shukla &lt;shouryashukla.oo@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>submodule: port subcommand 'set-url' from shell to C</title>
<updated>2020-05-08T16:17:55Z</updated>
<author>
<name>Shourya Shukla</name>
<email>shouryashukla.oo@gmail.com</email>
</author>
<published>2020-05-08T06:21:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6417cf9c21e9b3f450cd78352d19f43a4dd5a495'/>
<id>urn:sha1:6417cf9c21e9b3f450cd78352d19f43a4dd5a495</id>
<content type='text'>
Convert submodule subcommand 'set-url' to a builtin. Port 'set-url' to
'submodule--helper.c' and call the latter via 'git-submodule.sh'.

Signed-off-by: Shourya Shukla &lt;shouryashukla.oo@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
