Skip to content

Commit 18d3437

Browse files
committed
Add options --submodule and --conflict
These options check if considered git directories are submodules (resp. submodules in merge conflict) compared to the origin directory. Also, negative options --not-submodule and --no-conflict.
1 parent ef81688 commit 18d3437

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

git-iterate

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ branch_type=""
5757
some_remote=""
5858
ref_ff_to_ref=""
5959
ref_strict_ff_to_ref=""
60+
submodule=""
61+
conflict=""
6062
for folder in "$@"
6163
do
6264
if [ -z "$options" ]; then
@@ -164,6 +166,22 @@ do
164166
shift
165167
ref_strict_ff_to_ref=`echo -n "$folder"|cut -c24-`
166168
continue
169+
elif [ "$folder" = "--submodule" ]; then
170+
shift
171+
submodule="1"
172+
continue
173+
elif [ "$folder" = "--not-submodule" ]; then
174+
shift
175+
submodule="0"
176+
continue
177+
elif [ "$folder" = "--conflict" ]; then
178+
shift
179+
conflict="1"
180+
continue
181+
elif [ "$folder" = "--no-conflict" ]; then
182+
shift
183+
conflict="0"
184+
continue
167185
fi
168186
fi
169187
options="1"
@@ -449,6 +467,30 @@ do
449467
continue
450468
fi
451469
fi
470+
if [ -n "$conflict" ]; then
471+
status=$(LANG="en" git -C "$OLDPWD" status --short -- "$git_folder"|cut -d' ' -f1)
472+
if [ "$status" = "UU" -a "$conflict" = "0" ]; then
473+
cd "$OLDPWD"
474+
continue
475+
elif [ "$status" != "UU" -a "$conflict" = "1" ]; then
476+
cd "$OLDPWD"
477+
continue
478+
fi
479+
fi
480+
if [ -n "$submodule" ]; then
481+
if ! git -C "$OLDPWD" branch >/dev/null 2>&1; then
482+
cd "$OLDPWD"
483+
continue
484+
fi
485+
status=$(LANG="en" git -C "$OLDPWD" ls-files --cached --stage --full-name -- "$git_folder"|cut -d' ' -f1)
486+
if [ "$status" = "160000" -a "$submodule" = "0" ]; then
487+
cd "$OLDPWD"
488+
continue
489+
elif [ "$status" != "160000" -a "$submodule" = "1" ]; then
490+
cd "$OLDPWD"
491+
continue
492+
fi
493+
fi
452494
if [ "$display_only" = "true" ]; then
453495
echo "$git_folder"
454496
cd "$OLDPWD"

0 commit comments

Comments
 (0)