Re: git diff across submodules
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 20, 2012, 20:52 UTC
- Message-ID
- <7vr4pwa02u.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <505B73CE.5030009@web.de>
Jens Lehmann <Jens.Lehmann@web.de> writes:
Show 5 quoted lines
> That's pretty cool! Even though diff options like --stat and --name-only > still won't take into account what happened inside the submodule this > approach makes it possible to see the diff recursively. Wouldn't it make > sense add this script to contrib (after teaching it new and removed > submodules and documenting its use in a few lines after the shebang)?
A few things somebody may want to work on while doing that "few lines of documentation" I know about are:
* From the core side, pass options that are releavant when generating patch (i.e. with p) in environment variables to the external diff script;
* Not using "s/$1" and "m/$1" as prefix; instead, pass src/dst prefix values (i.e. s/ and m/) from the core side in environment variables, and make the external diff script itself aware of possibly nested submodules, e.g.
SUBMODULE_PATH="${SUBMODULE_PATH}$1"
export SUBMODULE_PATH
exec git --no-pager diff -p \
--src-prefix="$SRC_PREFIX/$SUBMODULE_PATH" \
--dst-prefix="$DST_PREFIX/$SUBMODULE_PATH" "$3" "$6"After people gain sufficient experience with it, as the next step, we can think about how to handle --stat and other options when we are run without -p (currently the attribute mechanism would not trigger) and then we can call the result a native "diff that recurses into submodules" that people can use without setting up the attributes based mechanism.