mirror of
https://github.com/git/git
synced 2024-09-13 21:34:42 +00:00
Merge branch 'jk/ls-files-recurse-submodules-fix'
"ls-files --recurse-submodules" did not quite work well in a project with nested submodules. * jk/ls-files-recurse-submodules-fix: ls-files: fix path used when recursing into submodules ls-files: fix recurse-submodules with nested submodules
This commit is contained in:
commit
2d646e3e1f
|
@ -15,6 +15,7 @@
|
||||||
#include "string-list.h"
|
#include "string-list.h"
|
||||||
#include "pathspec.h"
|
#include "pathspec.h"
|
||||||
#include "run-command.h"
|
#include "run-command.h"
|
||||||
|
#include "submodule.h"
|
||||||
|
|
||||||
static int abbrev;
|
static int abbrev;
|
||||||
static int show_deleted;
|
static int show_deleted;
|
||||||
|
@ -202,6 +203,10 @@ static void show_gitlink(const struct cache_entry *ce)
|
||||||
{
|
{
|
||||||
struct child_process cp = CHILD_PROCESS_INIT;
|
struct child_process cp = CHILD_PROCESS_INIT;
|
||||||
int status;
|
int status;
|
||||||
|
char *dir;
|
||||||
|
|
||||||
|
prepare_submodule_repo_env(&cp.env_array);
|
||||||
|
argv_array_push(&cp.env_array, GIT_DIR_ENVIRONMENT);
|
||||||
|
|
||||||
if (prefix_len)
|
if (prefix_len)
|
||||||
argv_array_pushf(&cp.env_array, "%s=%s",
|
argv_array_pushf(&cp.env_array, "%s=%s",
|
||||||
|
@ -217,8 +222,10 @@ static void show_gitlink(const struct cache_entry *ce)
|
||||||
argv_array_pushv(&cp.args, submodule_options.argv);
|
argv_array_pushv(&cp.args, submodule_options.argv);
|
||||||
|
|
||||||
cp.git_cmd = 1;
|
cp.git_cmd = 1;
|
||||||
cp.dir = ce->name;
|
dir = mkpathdup("%s/%s", get_git_work_tree(), ce->name);
|
||||||
|
cp.dir = dir;
|
||||||
status = run_command(&cp);
|
status = run_command(&cp);
|
||||||
|
free(dir);
|
||||||
if (status)
|
if (status)
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,10 +77,22 @@ test_expect_success 'ls-files recurses more than 1 level' '
|
||||||
git -C submodule/subsub commit -m "add d" &&
|
git -C submodule/subsub commit -m "add d" &&
|
||||||
git -C submodule submodule add ./subsub &&
|
git -C submodule submodule add ./subsub &&
|
||||||
git -C submodule commit -m "added subsub" &&
|
git -C submodule commit -m "added subsub" &&
|
||||||
|
git submodule absorbgitdirs &&
|
||||||
git ls-files --recurse-submodules >actual &&
|
git ls-files --recurse-submodules >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'ls-files works with GIT_DIR' '
|
||||||
|
cat >expect <<-\EOF &&
|
||||||
|
.gitmodules
|
||||||
|
c
|
||||||
|
subsub/d
|
||||||
|
EOF
|
||||||
|
|
||||||
|
git --git-dir=submodule/.git ls-files --recurse-submodules >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success '--recurse-submodules and pathspecs setup' '
|
test_expect_success '--recurse-submodules and pathspecs setup' '
|
||||||
echo e >submodule/subsub/e.txt &&
|
echo e >submodule/subsub/e.txt &&
|
||||||
git -C submodule/subsub add e.txt &&
|
git -C submodule/subsub add e.txt &&
|
||||||
|
|
Loading…
Reference in a new issue