* [PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts
@ 2011-03-22 8:56 Nicolas Morey-Chaisemartin
2011-03-22 19:22 ` Jens Lehmann
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Morey-Chaisemartin @ 2011-03-22 8:56 UTC (permalink / raw)
To: git
During a merge with conflict on a submodule, the submodule appears 3 times in git ls-files (stage 1,2,3) which caused the submodule to be used 3 times in git submodule init, sync, update and status command.
This patch filters the results of git ls-files to generate a single entry for conflicting submodules with a 0 SHA1 and 'U' as stage.
After this patch:
- init and sync behave as previously but only once per submodule
- update skips submodule with merge conflicts
- status now display a null SHA1 prefixed by 'U' for submodule with merge conflicts
Signed-off-by: Nicolas Morey-Chaisemartin <nicolas@morey-chaisemartin.com>
---
git-submodule.sh | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 3a13397..7f6b3cf 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -72,7 +72,24 @@ resolve_relative_url ()
#
module_list()
{
- git ls-files --error-unmatch --stage -- "$@" | sane_grep '^160000 '
+ git ls-files --error-unmatch --stage -- "$@" |
+ perl -e '
+ my %unmerged = ();
+ my ($null_sha1) = ("0" x 40);
+ while (<STDIN>) {
+ chomp;
+ my ($mode, $sha1, $stage, $path) =
+ /^([0-7]+) ([0-9a-f]{40}) ([0-3])\t(.*)$/;
+ next unless $mode eq "160000";
+ if ($stage ne "0") {
+ if (!$unmerged{$path}++) {
+ print "$mode $null_sha1 U\t$path\n";
+ }
+ next;
+ }
+ print "$_\n";
+ }
+ '
}
#
@@ -427,6 +444,11 @@ cmd_update()
module_list "$@" |
while read mode sha1 stage path
do
+ if test "$stage" = U
+ then
+ echo >&2 "Skipping unmerged submodule $path"
+ continue
+ fi
name=$(module_name "$path") || exit
url=$(git config submodule."$name".url)
update_module=$(git config submodule."$name".update)
@@ -770,6 +792,11 @@ cmd_status()
name=$(module_name "$path") || exit
url=$(git config submodule."$name".url)
displaypath="$prefix$path"
+ if test "$stage" = U
+ then
+ say "U$sha1 $displaypath"
+ continue
+ fi
if test -z "$url" || ! test -d "$path"/.git -o -f "$path"/.git
then
say "-$sha1 $displaypath"
--
1.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts
2011-03-22 8:56 [PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts Nicolas Morey-Chaisemartin
@ 2011-03-22 19:22 ` Jens Lehmann
2011-03-22 21:41 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Jens Lehmann @ 2011-03-22 19:22 UTC (permalink / raw)
To: Nicolas Morey-Chaisemartin; +Cc: git
Thanks, that fixes it nicely!
Am 22.03.2011 09:56, schrieb Nicolas Morey-Chaisemartin:
> During a merge with conflict on a submodule, the submodule appears 3 times in git ls-files (stage 1,2,3) which caused the submodule to be used 3 times in git submodule init, sync, update and status command.
> This patch filters the results of git ls-files to generate a single entry for conflicting submodules with a 0 SHA1 and 'U' as stage.
Nit: Usually we wrap commit messages at about 72 characters.
> After this patch:
> - init and sync behave as previously but only once per submodule
> - update skips submodule with merge conflicts
> - status now display a null SHA1 prefixed by 'U' for submodule with merge conflicts
A test case would be nice (t7405 looks like the right spot for one).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts
2011-03-22 19:22 ` Jens Lehmann
@ 2011-03-22 21:41 ` Junio C Hamano
2011-03-24 6:58 ` Nicolas Morey-Chaisemartin
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2011-03-22 21:41 UTC (permalink / raw)
To: Jens Lehmann; +Cc: Nicolas Morey-Chaisemartin, git
Jens Lehmann <Jens.Lehmann@web.de> writes:
> Thanks, that fixes it nicely!
>
> Am 22.03.2011 09:56, schrieb Nicolas Morey-Chaisemartin:
>> During a merge with conflict on a submodule, the submodule appears 3 times in git ls-files (stage 1,2,3) which caused the submodule to be used 3 times in git submodule init, sync, update and status command.
>> This patch filters the results of git ls-files to generate a single entry for conflicting submodules with a 0 SHA1 and 'U' as stage.
>
> Nit: Usually we wrap commit messages at about 72 characters.
Also it is very dissapointing to see that none of the careful thinking
that was needed while deciding what each subcommand should do was copied
from <7vhbb1320t.fsf@alter.siamese.dyndns.org> -- did I just waste my
time trying to guide this topic forward?
>> After this patch:
>> - init and sync behave as previously but only once per submodule
>> - update skips submodule with merge conflicts
>> - status now display a null SHA1 prefixed by 'U' for submodule with merge conflicts
>
> A test case would be nice (t7405 looks like the right spot for one).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts
2011-03-22 21:41 ` Junio C Hamano
@ 2011-03-24 6:58 ` Nicolas Morey-Chaisemartin
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Morey-Chaisemartin @ 2011-03-24 6:58 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On 03/22/2011 10:41 PM, Junio C Hamano wrote:
> Jens Lehmann <Jens.Lehmann@web.de> writes:
>
>> Thanks, that fixes it nicely!
>>
>> Am 22.03.2011 09:56, schrieb Nicolas Morey-Chaisemartin:
>>> During a merge with conflict on a submodule, the submodule appears 3 times in git ls-files (stage 1,2,3) which caused the submodule to be used 3 times in git submodule init, sync, update and status command.
>>> This patch filters the results of git ls-files to generate a single entry for conflicting submodules with a 0 SHA1 and 'U' as stage.
>> Nit: Usually we wrap commit messages at about 72 characters.
> Also it is very dissapointing to see that none of the careful thinking
> that was needed while deciding what each subcommand should do was copied
> from <7vhbb1320t.fsf@alter.siamese.dyndns.org> -- did I just waste my
> time trying to guide this topic forward?
>
Sorry about that. I wasn't sure how much details you put in commit logs. I guess it wasn't enough.
I'll fix this as soon as I have added a test case for the 'U' status
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-24 6:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-22 8:56 [PATCH 1/2] git-submodule.sh: Handle submodules with merge conflicts Nicolas Morey-Chaisemartin
2011-03-22 19:22 ` Jens Lehmann
2011-03-22 21:41 ` Junio C Hamano
2011-03-24 6:58 ` Nicolas Morey-Chaisemartin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).