2008-05-02 15:35:34 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2008-09-03 10:59:33 +02:00
|
|
|
test_description='git status for submodule'
|
2008-05-02 15:35:34 +02:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2011-05-14 18:26:30 +02:00
|
|
|
test_create_repo_with_commit () {
|
|
|
|
test_create_repo "$1" &&
|
2010-01-16 18:42:24 +01:00
|
|
|
(
|
2011-05-14 18:26:30 +02:00
|
|
|
cd "$1" &&
|
2010-01-16 18:42:24 +01:00
|
|
|
: >bar &&
|
|
|
|
git add bar &&
|
|
|
|
git commit -m " Add bar" &&
|
|
|
|
: >foo &&
|
|
|
|
git add foo &&
|
|
|
|
git commit -m " Add foo"
|
2011-05-14 18:26:30 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
short status: improve reporting for submodule changes
If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:
$ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
$ echo hello >gerrit/plugins/replication/stray-file
$ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
$ git -C gerrit status --short
M plugins/replication
This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index. But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.
Introduce new status letters " ?" and " m" for this. These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.
Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.
To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule. They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).
While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short". We only change
"git status --short".
Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:
$ git -C gerrit status --porcelain=2
1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
$ git -C gerrit status
[...]
modified: plugins/replication (modified content, untracked content)
Scripts caring about these distinctions should use --porcelain=2.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-30 00:26:15 +02:00
|
|
|
sanitize_output () {
|
2018-05-13 04:24:15 +02:00
|
|
|
sed -e "s/$OID_REGEX/HASH/" -e "s/$OID_REGEX/HASH/" output >output2 &&
|
short status: improve reporting for submodule changes
If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:
$ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
$ echo hello >gerrit/plugins/replication/stray-file
$ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
$ git -C gerrit status --short
M plugins/replication
This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index. But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.
Introduce new status letters " ?" and " m" for this. These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.
Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.
To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule. They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).
While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short". We only change
"git status --short".
Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:
$ git -C gerrit status --porcelain=2
1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
$ git -C gerrit status
[...]
modified: plugins/replication (modified content, untracked content)
Scripts caring about these distinctions should use --porcelain=2.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-30 00:26:15 +02:00
|
|
|
mv output2 output
|
|
|
|
}
|
|
|
|
|
2020-07-30 01:14:05 +02:00
|
|
|
sanitize_diff () {
|
|
|
|
sed -e "/^index [0-9a-f,]*\.\.[0-9a-f]*/d" "$1"
|
|
|
|
}
|
|
|
|
|
short status: improve reporting for submodule changes
If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:
$ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
$ echo hello >gerrit/plugins/replication/stray-file
$ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
$ git -C gerrit status --short
M plugins/replication
This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index. But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.
Introduce new status letters " ?" and " m" for this. These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.
Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.
To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule. They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).
While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short". We only change
"git status --short".
Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:
$ git -C gerrit status --porcelain=2
1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
$ git -C gerrit status
[...]
modified: plugins/replication (modified content, untracked content)
Scripts caring about these distinctions should use --porcelain=2.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-30 00:26:15 +02:00
|
|
|
|
2011-05-14 18:26:30 +02:00
|
|
|
test_expect_success 'setup' '
|
|
|
|
test_create_repo_with_commit sub &&
|
2010-01-16 18:42:24 +01:00
|
|
|
echo output > .gitignore &&
|
|
|
|
git add sub .gitignore &&
|
2008-05-02 15:35:34 +02:00
|
|
|
git commit -m "Add submodule sub"
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status clean' '
|
2010-01-16 18:42:24 +01:00
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "nothing to commit" output
|
2008-05-02 15:35:34 +02:00
|
|
|
'
|
2010-01-16 18:42:24 +01:00
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'commit --dry-run -a clean' '
|
2010-01-16 18:42:24 +01:00
|
|
|
test_must_fail git commit --dry-run -a >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "nothing to commit" output
|
2010-01-16 18:42:24 +01:00
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with modified file in submodule' '
|
2010-01-16 18:42:24 +01:00
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "changed" >sub/foo &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (modified content)" output
|
2010-01-16 18:42:24 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with modified file in submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "changed" >sub/foo &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
short status: improve reporting for submodule changes
If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:
$ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
$ echo hello >gerrit/plugins/replication/stray-file
$ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
$ git -C gerrit status --short
M plugins/replication
This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index. But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.
Introduce new status letters " ?" and " m" for this. These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.
Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.
To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule. They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).
While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short". We only change
"git status --short".
Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:
$ git -C gerrit status --porcelain=2
1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
$ git -C gerrit status
[...]
modified: plugins/replication (modified content, untracked content)
Scripts caring about these distinctions should use --porcelain=2.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-30 00:26:15 +02:00
|
|
|
test_expect_success 'status with modified file in submodule (short)' '
|
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "changed" >sub/foo &&
|
|
|
|
git status --short >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
m sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with added file in submodule' '
|
2010-01-16 18:42:24 +01:00
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (modified content)" output
|
2010-01-16 18:42:24 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added file in submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
short status: improve reporting for submodule changes
If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:
$ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
$ echo hello >gerrit/plugins/replication/stray-file
$ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
$ git -C gerrit status --short
M plugins/replication
This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index. But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.
Introduce new status letters " ?" and " m" for this. These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.
Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.
To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule. They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).
While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short". We only change
"git status --short".
Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:
$ git -C gerrit status --porcelain=2
1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
$ git -C gerrit status
[...]
modified: plugins/replication (modified content, untracked content)
Scripts caring about these distinctions should use --porcelain=2.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-30 00:26:15 +02:00
|
|
|
test_expect_success 'status with added file in submodule (short)' '
|
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status --short >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
m sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with untracked file in submodule' '
|
2010-01-16 18:42:24 +01:00
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (untracked content)" output
|
2010-01-16 18:42:24 +01:00
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status -uno with untracked file in submodule' '
|
2010-03-13 23:00:27 +01:00
|
|
|
git status -uno >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "^nothing to commit" output
|
2010-03-13 23:00:27 +01:00
|
|
|
'
|
|
|
|
|
2010-01-16 18:42:24 +01:00
|
|
|
test_expect_success 'status with untracked file in submodule (porcelain)' '
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
2008-05-02 15:35:34 +02:00
|
|
|
'
|
2010-01-16 18:42:24 +01:00
|
|
|
|
short status: improve reporting for submodule changes
If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:
$ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
$ echo hello >gerrit/plugins/replication/stray-file
$ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
$ git -C gerrit status --short
M plugins/replication
This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index. But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.
Introduce new status letters " ?" and " m" for this. These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.
Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.
To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule. They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).
While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short". We only change
"git status --short".
Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:
$ git -C gerrit status --porcelain=2
1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
$ git -C gerrit status
[...]
modified: plugins/replication (modified content, untracked content)
Scripts caring about these distinctions should use --porcelain=2.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-30 00:26:15 +02:00
|
|
|
test_expect_success 'status with untracked file in submodule (short)' '
|
|
|
|
git status --short >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
? sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with added and untracked file in submodule' '
|
2010-03-12 22:23:52 +01:00
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (modified content, untracked content)" output
|
2010-03-12 22:23:52 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added and untracked file in submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with modified file in modified submodule' '
|
2010-03-12 22:23:52 +01:00
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
rm sub/new-file &&
|
|
|
|
(cd sub && echo "next change" >foo && git commit -m "next change" foo) &&
|
|
|
|
echo "changed" >sub/foo &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (new commits, modified content)" output
|
2010-03-12 22:23:52 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with modified file in modified submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "changed" >sub/foo &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with added file in modified submodule' '
|
2010-03-12 22:23:52 +01:00
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (new commits, modified content)" output
|
2010-03-12 22:23:52 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added file in modified submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with untracked file in modified submodule' '
|
2010-03-12 22:23:52 +01:00
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (new commits, untracked content)" output
|
2010-03-12 22:23:52 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with untracked file in modified submodule (porcelain)' '
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with added and untracked file in modified submodule' '
|
2010-03-12 22:23:52 +01:00
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (new commits, modified content, untracked content)" output
|
2010-03-12 22:23:52 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2010-04-10 19:01:12 +02:00
|
|
|
test_expect_success 'setup .git file for sub' '
|
|
|
|
(cd sub &&
|
2018-07-02 02:24:03 +02:00
|
|
|
rm -f new-file &&
|
2010-04-10 19:01:12 +02:00
|
|
|
REAL="$(pwd)/../.real" &&
|
2018-07-02 02:24:03 +02:00
|
|
|
mv .git "$REAL" &&
|
2010-04-10 19:01:12 +02:00
|
|
|
echo "gitdir: $REAL" >.git) &&
|
|
|
|
echo .real >>.gitignore &&
|
|
|
|
git commit -m "added .real to .gitignore" .gitignore
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with added file in modified submodule with .git file' '
|
2010-04-10 19:01:12 +02:00
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (new commits, modified content)" output
|
2010-04-10 19:01:12 +02:00
|
|
|
'
|
|
|
|
|
2017-03-25 01:36:06 +01:00
|
|
|
test_expect_success 'status with a lot of untracked files in the submodule' '
|
|
|
|
(
|
2018-07-02 02:24:03 +02:00
|
|
|
cd sub &&
|
2017-03-25 01:36:06 +01:00
|
|
|
i=0 &&
|
|
|
|
while test $i -lt 1024
|
|
|
|
do
|
2018-07-02 02:24:03 +02:00
|
|
|
>some-file-$i &&
|
|
|
|
i=$(( $i + 1 )) || exit 1
|
2017-03-25 01:36:06 +01:00
|
|
|
done
|
|
|
|
) &&
|
|
|
|
git status --porcelain sub 2>err.actual &&
|
|
|
|
test_must_be_empty err.actual &&
|
|
|
|
rm err.actual
|
|
|
|
'
|
|
|
|
|
2008-05-02 15:35:34 +02:00
|
|
|
test_expect_success 'rm submodule contents' '
|
2017-03-25 01:36:06 +01:00
|
|
|
rm -rf sub &&
|
|
|
|
mkdir sub
|
2008-05-02 15:35:34 +02:00
|
|
|
'
|
2010-01-16 18:42:24 +01:00
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status clean (empty submodule dir)' '
|
2010-01-16 18:42:24 +01:00
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "nothing to commit" output
|
2008-05-02 15:35:34 +02:00
|
|
|
'
|
2010-01-16 18:42:24 +01:00
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status -a clean (empty submodule dir)' '
|
2010-01-16 18:42:24 +01:00
|
|
|
test_must_fail git commit --dry-run -a >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "nothing to commit" output
|
2008-05-02 15:35:34 +02:00
|
|
|
'
|
|
|
|
|
2011-05-14 18:26:30 +02:00
|
|
|
cat >status_expect <<\EOF
|
|
|
|
AA .gitmodules
|
|
|
|
A sub1
|
|
|
|
EOF
|
|
|
|
|
2011-05-14 18:26:58 +02:00
|
|
|
test_expect_success 'status with merge conflict in .gitmodules' '
|
2011-05-14 18:26:30 +02:00
|
|
|
git clone . super &&
|
|
|
|
test_create_repo_with_commit sub1 &&
|
|
|
|
test_tick &&
|
|
|
|
test_create_repo_with_commit sub2 &&
|
|
|
|
(
|
|
|
|
cd super &&
|
|
|
|
prev=$(git rev-parse HEAD) &&
|
|
|
|
git checkout -b add_sub1 &&
|
|
|
|
git submodule add ../sub1 &&
|
|
|
|
git commit -m "add sub1" &&
|
|
|
|
git checkout -b add_sub2 $prev &&
|
|
|
|
git submodule add ../sub2 &&
|
|
|
|
git commit -m "add sub2" &&
|
|
|
|
git checkout -b merge_conflict_gitmodules &&
|
|
|
|
test_must_fail git merge add_sub1 &&
|
|
|
|
git status -s >../status_actual 2>&1
|
|
|
|
) &&
|
|
|
|
test_cmp status_actual status_expect
|
|
|
|
'
|
|
|
|
|
|
|
|
sha1_merge_sub1=$(cd sub1 && git rev-parse HEAD)
|
|
|
|
sha1_merge_sub2=$(cd sub2 && git rev-parse HEAD)
|
|
|
|
short_sha1_merge_sub1=$(cd sub1 && git rev-parse --short HEAD)
|
|
|
|
short_sha1_merge_sub2=$(cd sub2 && git rev-parse --short HEAD)
|
|
|
|
cat >diff_expect <<\EOF
|
|
|
|
diff --cc .gitmodules
|
|
|
|
--- a/.gitmodules
|
|
|
|
+++ b/.gitmodules
|
|
|
|
@@@ -1,3 -1,3 +1,9 @@@
|
|
|
|
++<<<<<<< HEAD
|
|
|
|
+[submodule "sub2"]
|
|
|
|
+ path = sub2
|
|
|
|
+ url = ../sub2
|
|
|
|
++=======
|
|
|
|
+ [submodule "sub1"]
|
|
|
|
+ path = sub1
|
|
|
|
+ url = ../sub1
|
|
|
|
++>>>>>>> add_sub1
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat >diff_submodule_expect <<\EOF
|
|
|
|
diff --cc .gitmodules
|
|
|
|
--- a/.gitmodules
|
|
|
|
+++ b/.gitmodules
|
|
|
|
@@@ -1,3 -1,3 +1,9 @@@
|
|
|
|
++<<<<<<< HEAD
|
|
|
|
+[submodule "sub2"]
|
|
|
|
+ path = sub2
|
|
|
|
+ url = ../sub2
|
|
|
|
++=======
|
|
|
|
+ [submodule "sub1"]
|
|
|
|
+ path = sub1
|
|
|
|
+ url = ../sub1
|
|
|
|
++>>>>>>> add_sub1
|
|
|
|
EOF
|
|
|
|
|
2011-05-14 18:26:58 +02:00
|
|
|
test_expect_success 'diff with merge conflict in .gitmodules' '
|
2011-05-14 18:26:30 +02:00
|
|
|
(
|
|
|
|
cd super &&
|
|
|
|
git diff >../diff_actual 2>&1
|
|
|
|
) &&
|
2020-07-30 01:14:05 +02:00
|
|
|
sanitize_diff diff_actual >diff_sanitized &&
|
|
|
|
test_cmp diff_expect diff_sanitized
|
2011-05-14 18:26:30 +02:00
|
|
|
'
|
|
|
|
|
2011-05-14 18:26:58 +02:00
|
|
|
test_expect_success 'diff --submodule with merge conflict in .gitmodules' '
|
2011-05-14 18:26:30 +02:00
|
|
|
(
|
|
|
|
cd super &&
|
|
|
|
git diff --submodule >../diff_submodule_actual 2>&1
|
|
|
|
) &&
|
2020-07-30 01:14:05 +02:00
|
|
|
sanitize_diff diff_submodule_actual >diff_sanitized &&
|
|
|
|
test_cmp diff_submodule_expect diff_sanitized
|
2011-05-14 18:26:30 +02:00
|
|
|
'
|
|
|
|
|
short status: improve reporting for submodule changes
If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:
$ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
$ echo hello >gerrit/plugins/replication/stray-file
$ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
$ git -C gerrit status --short
M plugins/replication
This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index. But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.
Introduce new status letters " ?" and " m" for this. These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.
Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.
To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule. They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).
While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short". We only change
"git status --short".
Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:
$ git -C gerrit status --porcelain=2
1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
$ git -C gerrit status
[...]
modified: plugins/replication (modified content, untracked content)
Scripts caring about these distinctions should use --porcelain=2.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-30 00:26:15 +02:00
|
|
|
# We'll setup different cases for further testing:
|
|
|
|
# sub1 will contain a nested submodule,
|
|
|
|
# sub2 will have an untracked file
|
|
|
|
# sub3 will have an untracked repository
|
|
|
|
test_expect_success 'setup superproject with untracked file in nested submodule' '
|
|
|
|
(
|
|
|
|
cd super &&
|
|
|
|
git clean -dfx &&
|
2018-10-05 15:05:58 +02:00
|
|
|
git rm .gitmodules &&
|
|
|
|
git commit -m "remove .gitmodules" &&
|
short status: improve reporting for submodule changes
If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:
$ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
$ echo hello >gerrit/plugins/replication/stray-file
$ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
$ git -C gerrit status --short
M plugins/replication
This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index. But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.
Introduce new status letters " ?" and " m" for this. These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.
Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.
To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule. They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).
While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short". We only change
"git status --short".
Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:
$ git -C gerrit status --porcelain=2
1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
$ git -C gerrit status
[...]
modified: plugins/replication (modified content, untracked content)
Scripts caring about these distinctions should use --porcelain=2.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-30 00:26:15 +02:00
|
|
|
git submodule add -f ./sub1 &&
|
|
|
|
git submodule add -f ./sub2 &&
|
|
|
|
git submodule add -f ./sub1 sub3 &&
|
|
|
|
git commit -a -m "messy merge in superproject" &&
|
|
|
|
(
|
|
|
|
cd sub1 &&
|
|
|
|
git submodule add ../sub2 &&
|
|
|
|
git commit -a -m "add sub2 to sub1"
|
|
|
|
) &&
|
|
|
|
git add sub1 &&
|
|
|
|
git commit -a -m "update sub1 to contain nested sub"
|
|
|
|
) &&
|
|
|
|
echo content >super/sub1/sub2/file &&
|
|
|
|
echo content >super/sub2/file &&
|
|
|
|
git -C super/sub3 clone ../../sub2 untracked_repository
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with untracked file in nested submodule (porcelain)' '
|
|
|
|
git -C super status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub1
|
|
|
|
M sub2
|
|
|
|
M sub3
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '
|
|
|
|
git -C super status --porcelain=2 >output &&
|
|
|
|
sanitize_output output &&
|
|
|
|
diff output - <<-\EOF
|
2017-03-30 00:26:16 +02:00
|
|
|
1 .M S..U 160000 160000 160000 HASH HASH sub1
|
short status: improve reporting for submodule changes
If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:
$ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
$ echo hello >gerrit/plugins/replication/stray-file
$ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
$ git -C gerrit status --short
M plugins/replication
This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index. But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.
Introduce new status letters " ?" and " m" for this. These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.
Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.
To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule. They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).
While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short". We only change
"git status --short".
Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:
$ git -C gerrit status --porcelain=2
1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
$ git -C gerrit status
[...]
modified: plugins/replication (modified content, untracked content)
Scripts caring about these distinctions should use --porcelain=2.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-30 00:26:15 +02:00
|
|
|
1 .M S..U 160000 160000 160000 HASH HASH sub2
|
|
|
|
1 .M S..U 160000 160000 160000 HASH HASH sub3
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with untracked file in nested submodule (short)' '
|
|
|
|
git -C super status --short >output &&
|
|
|
|
diff output - <<-\EOF
|
2017-03-30 00:26:16 +02:00
|
|
|
? sub1
|
short status: improve reporting for submodule changes
If I add an untracked file to a submodule or modify a tracked file,
currently "git status --short" treats the change in the same way as
changes to the current HEAD of the submodule:
$ git clone --quiet --recurse-submodules https://gerrit.googlesource.com/gerrit
$ echo hello >gerrit/plugins/replication/stray-file
$ sed -i -e 's/.*//' gerrit/plugins/replication/.mailmap
$ git -C gerrit status --short
M plugins/replication
This is by analogy with ordinary files, where "M" represents a change
that has not been added yet to the index. But this change cannot be
added to the index without entering the submodule, "git add"-ing it,
and running "git commit", so the analogy is counterproductive.
Introduce new status letters " ?" and " m" for this. These are similar
to the existing "??" and " M" but mean that the submodule (not the
parent project) has new untracked files and modified files, respectively.
The user can use "git add" and "git commit" from within the submodule to
add them.
Changes to the submodule's HEAD commit can be recorded in the index with
a plain "git add -u" and are shown with " M", like today.
To avoid excessive clutter, show at most one of " ?", " m", and " M" for
the submodule. They represent increasing levels of change --- the last
one that applies is shown (e.g., " m" if there are both modified files
and untracked files in the submodule, or " M" if the submodule's HEAD
has been modified and it has untracked files).
While making these changes, we need to make sure to not break porcelain
level 1, which shares code with "status --short". We only change
"git status --short".
Non-short "git status" and "git status --porcelain=2" already handle
these cases by showing more detail:
$ git -C gerrit status --porcelain=2
1 .M S.MU 160000 160000 160000 305c864db28eb0c77c8499bc04c87de3f849cf3c 305c864db28eb0c77c8499bc04c87de3f849cf3c plugins/replication
$ git -C gerrit status
[...]
modified: plugins/replication (modified content, untracked content)
Scripts caring about these distinctions should use --porcelain=2.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-30 00:26:15 +02:00
|
|
|
? sub2
|
|
|
|
? sub3
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup superproject with modified file in nested submodule' '
|
|
|
|
git -C super/sub1/sub2 add file &&
|
|
|
|
git -C super/sub2 add file
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added file in nested submodule (porcelain)' '
|
|
|
|
git -C super status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub1
|
|
|
|
M sub2
|
|
|
|
M sub3
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added file in nested submodule (porcelain=2)' '
|
|
|
|
git -C super status --porcelain=2 >output &&
|
|
|
|
sanitize_output output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
1 .M S.M. 160000 160000 160000 HASH HASH sub1
|
|
|
|
1 .M S.M. 160000 160000 160000 HASH HASH sub2
|
|
|
|
1 .M S..U 160000 160000 160000 HASH HASH sub3
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added file in nested submodule (short)' '
|
|
|
|
git -C super status --short >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
m sub1
|
|
|
|
m sub2
|
|
|
|
? sub3
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2008-05-02 15:35:34 +02:00
|
|
|
test_done
|