* [PATCHv3 0/4] git-rm absorbs submodule git directory before deletion
From: Stefan Beller @ 2016-12-14 22:40 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, sandals, Stefan Beller
v3:
* removed the patch to enhance ok_to_remove_submodule to absorb the submodule
if needed
* Removed all the error reporting from git-rm that was related to submodule
git directories not absorbed.
* instead just absorb the git repositories or let the absorb function die
with an appropriate error message.
v2:
* new base where to apply the patch:
sb/submodule-embed-gitdir merged with sb/t3600-cleanup.
I got merge conflicts and resolved them this way:
#@@@ -709,9 -687,10 +687,9 @@@ test_expect_success 'checking out a com
# git commit -m "submodule removal" submod &&
# git checkout HEAD^ &&
# git submodule update &&
#- git checkout -q HEAD^ 2>actual &&
#+ git checkout -q HEAD^ &&
# git checkout -q master 2>actual &&
# - echo "warning: unable to rmdir submod: Directory not empty" >expected &&
# - test_i18ncmp expected actual &&
# + test_i18ngrep "^warning: unable to rmdir submod:" actual &&
# git status -s submod >actual &&
# echo "?? submod/" >expected &&
# test_cmp expected actual &&
#
* improved commit message in "ok_to_remove_submodule: absorb the submodule git dir"
(David Turner offered me some advice on how to write better English off list)
* simplified code in last patch:
-> dropped wrong comment for fallthrough
-> moved redundant code out of both bodies of an if-clause.
* Fixed last patchs commit message to have "or_die" instead of or_dir.
v1:
The "checkout --recurse-submodules" series got too large to comfortably send
it out for review, so I had to break it up into smaller series'; this is the
first subseries, but it makes sense on its own.
This series teaches git-rm to absorb the git directory of a submodule instead
of failing and complaining about the git directory preventing deletion.
It applies on origin/sb/submodule-embed-gitdir.
Any feedback welcome!
Thanks,
Stefan
Stefan Beller (4):
submodule.h: add extern keyword to functions
submodule: modernize ok_to_remove_submodule to use argv_array
submodule: add flags to ok_to_remove_submodule
rm: add absorb a submodules git dir before deletion
builtin/rm.c | 78 +++++++++++++++--------------------------------------------
cache.h | 2 ++
entry.c | 8 ++++++
submodule.c | 31 +++++++++++++++---------
submodule.h | 58 +++++++++++++++++++++++++-------------------
t/t3600-rm.sh | 39 ++++++++++++------------------
6 files changed, 97 insertions(+), 119 deletions(-)
--
2.11.0.rc2.35.g26e18c9
^ permalink raw reply
* [PATCHv3 2/4] submodule: modernize ok_to_remove_submodule to use argv_array
From: Stefan Beller @ 2016-12-14 22:40 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, sandals, Stefan Beller
In-Reply-To: <20161214224101.6211-1-sbeller@google.com>
Instead of constructing the NULL terminated array ourselves, we
should make use of the argv_array infrastructure.
While at it, adapt the error messages to reflect the actual invocation.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
submodule.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/submodule.c b/submodule.c
index 45ccfb7ab4..9f0b544ebe 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1023,13 +1023,6 @@ int ok_to_remove_submodule(const char *path)
{
ssize_t len;
struct child_process cp = CHILD_PROCESS_INIT;
- const char *argv[] = {
- "status",
- "--porcelain",
- "-u",
- "--ignore-submodules=none",
- NULL,
- };
struct strbuf buf = STRBUF_INIT;
int ok_to_remove = 1;
@@ -1039,14 +1032,15 @@ int ok_to_remove_submodule(const char *path)
if (!submodule_uses_gitfile(path))
return 0;
- cp.argv = argv;
+ argv_array_pushl(&cp.args, "status", "--porcelain", "-u",
+ "--ignore-submodules=none", NULL);
prepare_submodule_repo_env(&cp.env_array);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.out = -1;
cp.dir = path;
if (start_command(&cp))
- die("Could not run 'git status --porcelain -uall --ignore-submodules=none' in submodule %s", path);
+ die(_("could not run 'git status --porcelain -u --ignore-submodules=none' in submodule %s"), path);
len = strbuf_read(&buf, cp.out, 1024);
if (len > 2)
@@ -1054,7 +1048,7 @@ int ok_to_remove_submodule(const char *path)
close(cp.out);
if (finish_command(&cp))
- die("'git status --porcelain -uall --ignore-submodules=none' failed in submodule %s", path);
+ die(_("'git status --porcelain -u --ignore-submodules=none' failed in submodule %s"), path);
strbuf_release(&buf);
return ok_to_remove;
--
2.11.0.rc2.35.g26e18c9
^ permalink raw reply related
* [PATCHv3 1/4] submodule.h: add extern keyword to functions
From: Stefan Beller @ 2016-12-14 22:40 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, sandals, Stefan Beller
In-Reply-To: <20161214224101.6211-1-sbeller@google.com>
As the upcoming series will add a lot of functions to the submodule
header, let's first make the header consistent to the rest of the project
by adding the extern keyword to functions.
As per the CodingGuidelines we try to stay below 80 characters per line,
so adapt all those functions to stay below 80 characters that are already
using more than one line. Those function using just one line are better
kept in one line than breaking them up into multiple lines just for the
goal of staying below the character limit as it makes grepping
for functions easier if they are one liners.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
submodule.h | 55 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 30 insertions(+), 25 deletions(-)
diff --git a/submodule.h b/submodule.h
index 6229054b99..61fb610749 100644
--- a/submodule.h
+++ b/submodule.h
@@ -29,50 +29,55 @@ struct submodule_update_strategy {
};
#define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED, NULL}
-int is_staging_gitmodules_ok(void);
-int update_path_in_gitmodules(const char *oldpath, const char *newpath);
-int remove_path_from_gitmodules(const char *path);
-void stage_updated_gitmodules(void);
-void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
+extern int is_staging_gitmodules_ok(void);
+extern int update_path_in_gitmodules(const char *oldpath, const char *newpath);
+extern int remove_path_from_gitmodules(const char *path);
+extern void stage_updated_gitmodules(void);
+extern void set_diffopt_flags_from_submodule_config(struct diff_options *,
const char *path);
-int submodule_config(const char *var, const char *value, void *cb);
-void gitmodules_config(void);
-int parse_submodule_update_strategy(const char *value,
+extern int submodule_config(const char *var, const char *value, void *cb);
+extern void gitmodules_config(void);
+extern int parse_submodule_update_strategy(const char *value,
struct submodule_update_strategy *dst);
-const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
-void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
-void show_submodule_summary(FILE *f, const char *path,
+extern const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
+extern void handle_ignore_submodules_arg(struct diff_options *, const char *);
+extern void show_submodule_summary(FILE *f, const char *path,
const char *line_prefix,
struct object_id *one, struct object_id *two,
unsigned dirty_submodule, const char *meta,
const char *del, const char *add, const char *reset);
-void show_submodule_inline_diff(FILE *f, const char *path,
+extern void show_submodule_inline_diff(FILE *f, const char *path,
const char *line_prefix,
struct object_id *one, struct object_id *two,
unsigned dirty_submodule, const char *meta,
const char *del, const char *add, const char *reset,
const struct diff_options *opt);
-void set_config_fetch_recurse_submodules(int value);
-void check_for_new_submodule_commits(unsigned char new_sha1[20]);
-int fetch_populated_submodules(const struct argv_array *options,
+extern void set_config_fetch_recurse_submodules(int value);
+extern void check_for_new_submodule_commits(unsigned char new_sha1[20]);
+extern int fetch_populated_submodules(const struct argv_array *options,
const char *prefix, int command_line_option,
int quiet, int max_parallel_jobs);
-unsigned is_submodule_modified(const char *path, int ignore_untracked);
-int submodule_uses_gitfile(const char *path);
-int ok_to_remove_submodule(const char *path);
-int merge_submodule(unsigned char result[20], const char *path, const unsigned char base[20],
- const unsigned char a[20], const unsigned char b[20], int search);
-int find_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name,
- struct string_list *needs_pushing);
-int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name);
-int parallel_submodules(void);
+extern unsigned is_submodule_modified(const char *path, int ignore_untracked);
+extern int submodule_uses_gitfile(const char *path);
+extern int ok_to_remove_submodule(const char *path);
+extern int merge_submodule(unsigned char result[20], const char *path,
+ const unsigned char base[20],
+ const unsigned char a[20],
+ const unsigned char b[20], int search);
+extern int find_unpushed_submodules(unsigned char new_sha1[20],
+ const char *remotes_name,
+ struct string_list *needs_pushing);
+extern int push_unpushed_submodules(unsigned char new_sha1[20],
+ const char *remotes_name);
+extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
+extern int parallel_submodules(void);
/*
* Prepare the "env_array" parameter of a "struct child_process" for executing
* a submodule by clearing any repo-specific envirionment variables, but
* retaining any config in the environment.
*/
-void prepare_submodule_repo_env(struct argv_array *out);
+extern void prepare_submodule_repo_env(struct argv_array *out);
#define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0)
extern void absorb_git_dir_into_superproject(const char *prefix,
--
2.11.0.rc2.35.g26e18c9
^ permalink raw reply related
* [PATCHv3 3/4] submodule: add flags to ok_to_remove_submodule
From: Stefan Beller @ 2016-12-14 22:41 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, sandals, Stefan Beller
In-Reply-To: <20161214224101.6211-1-sbeller@google.com>
In different contexts the question whether deleting a submodule is ok
to remove may be answered differently.
In 293ab15eea (submodule: teach rm to remove submodules unless they
contain a git directory, 2012-09-26) a case was made that we can safely
ignore ignored untracked files for removal as we explicitely ask for the
removal of the submodule.
In a later patch we want to remove submodules even when the user doesn't
explicitly ask for it (e.g. checking out a tree-ish in which the submodule
doesn't exist). In that case we want to be more careful when it comes
to deletion of untracked files. As of this patch it is unclear how this
will be implemented exactly, so we'll offer flags in which the caller
can specify how the different untracked files ought to be handled.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
builtin/rm.c | 3 ++-
submodule.c | 23 +++++++++++++++++++----
submodule.h | 5 ++++-
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/builtin/rm.c b/builtin/rm.c
index 3f3e24eb36..fdd7183f61 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -187,7 +187,8 @@ static int check_local_mod(struct object_id *head, int index_only)
*/
if (ce_match_stat(ce, &st, 0) ||
(S_ISGITLINK(ce->ce_mode) &&
- !ok_to_remove_submodule(ce->name)))
+ !ok_to_remove_submodule(ce->name,
+ SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)))
local_changes = 1;
/*
diff --git a/submodule.c b/submodule.c
index 9f0b544ebe..2d13744b06 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1019,7 +1019,7 @@ int submodule_uses_gitfile(const char *path)
return 1;
}
-int ok_to_remove_submodule(const char *path)
+int ok_to_remove_submodule(const char *path, unsigned flags)
{
ssize_t len;
struct child_process cp = CHILD_PROCESS_INIT;
@@ -1032,15 +1032,27 @@ int ok_to_remove_submodule(const char *path)
if (!submodule_uses_gitfile(path))
return 0;
- argv_array_pushl(&cp.args, "status", "--porcelain", "-u",
+ argv_array_pushl(&cp.args, "status", "--porcelain",
"--ignore-submodules=none", NULL);
+
+ if (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED)
+ argv_array_push(&cp.args, "-uno");
+ else
+ argv_array_push(&cp.args, "-uall");
+
+ if (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED))
+ argv_array_push(&cp.args, "--ignored");
+
prepare_submodule_repo_env(&cp.env_array);
cp.git_cmd = 1;
cp.no_stdin = 1;
cp.out = -1;
cp.dir = path;
if (start_command(&cp))
- die(_("could not run 'git status --porcelain -u --ignore-submodules=none' in submodule %s"), path);
+ die(_("could not run 'git status --porcelain --ignore-submodules=none %s %s' in submodule '%s'"),
+ (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED) ? "-uno" : "-uall",
+ (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)) ? "--ignored" : "",
+ path);
len = strbuf_read(&buf, cp.out, 1024);
if (len > 2)
@@ -1048,7 +1060,10 @@ int ok_to_remove_submodule(const char *path)
close(cp.out);
if (finish_command(&cp))
- die(_("'git status --porcelain -u --ignore-submodules=none' failed in submodule %s"), path);
+ die(_("'git status --porcelain --ignore-submodules=none %s %s' failed in submodule '%s'"),
+ (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED) ? "-uno" : "-uall",
+ (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)) ? "--ignored" : "",
+ path);
strbuf_release(&buf);
return ok_to_remove;
diff --git a/submodule.h b/submodule.h
index 61fb610749..3ed3aa479a 100644
--- a/submodule.h
+++ b/submodule.h
@@ -59,7 +59,10 @@ extern int fetch_populated_submodules(const struct argv_array *options,
int quiet, int max_parallel_jobs);
extern unsigned is_submodule_modified(const char *path, int ignore_untracked);
extern int submodule_uses_gitfile(const char *path);
-extern int ok_to_remove_submodule(const char *path);
+
+#define SUBMODULE_REMOVAL_IGNORE_UNTRACKED (1<<0)
+#define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<1)
+extern int ok_to_remove_submodule(const char *path, unsigned flags);
extern int merge_submodule(unsigned char result[20], const char *path,
const unsigned char base[20],
const unsigned char a[20],
--
2.11.0.rc2.35.g26e18c9
^ permalink raw reply related
* [PATCHv3 4/4] rm: add absorb a submodules git dir before deletion
From: Stefan Beller @ 2016-12-14 22:41 UTC (permalink / raw)
To: gitster; +Cc: git, David.Turner, bmwill, sandals, Stefan Beller
In-Reply-To: <20161214224101.6211-1-sbeller@google.com>
When deleting a submodule, we need to keep the actual git directory around,
such that we do not lose local changes in there and at a later checkout
of the submodule we don't need to clone it again.
Now that the functionality is available to absorb the git directory of a
submodule, rewrite the checking in git-rm to not complain, but rather
relocate the git directories inside the superproject.
An alternative solution was discussed to have a function
`depopulate_submodule`, that couples the check for its git directory and
possible relocation before the the removal, such that it is less likely to
miss the check in the future, but the indirection with such a function
added seemed also complex. The reason for that was that this possible
move of the git directory was also implemented in `ok_to_remove_submodule`,
such that this function could truthfully answer whether it is ok to remove
the submodule.
The solution proposed here defers all these checks to the caller.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
builtin/rm.c | 75 ++++++++++++++---------------------------------------------
cache.h | 2 ++
entry.c | 8 +++++++
t/t3600-rm.sh | 39 ++++++++++++-------------------
4 files changed, 42 insertions(+), 82 deletions(-)
diff --git a/builtin/rm.c b/builtin/rm.c
index fdd7183f61..025ef4c735 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -59,27 +59,9 @@ static void print_error_files(struct string_list *files_list,
}
}
-static void error_removing_concrete_submodules(struct string_list *files, int *errs)
-{
- print_error_files(files,
- Q_("the following submodule (or one of its nested "
- "submodules)\n"
- "uses a .git directory:",
- "the following submodules (or one of their nested "
- "submodules)\n"
- "use a .git directory:", files->nr),
- _("\n(use 'rm -rf' if you really want to remove "
- "it including all of its history)"),
- errs);
- string_list_clear(files, 0);
-}
-
-static int check_submodules_use_gitfiles(void)
+static void submodules_absorb_gitdir_if_needed(const char *prefix)
{
int i;
- int errs = 0;
- struct string_list files = STRING_LIST_INIT_NODUP;
-
for (i = 0; i < list.nr; i++) {
const char *name = list.entry[i].name;
int pos;
@@ -99,12 +81,9 @@ static int check_submodules_use_gitfiles(void)
continue;
if (!submodule_uses_gitfile(name))
- string_list_append(&files, name);
+ absorb_git_dir_into_superproject(prefix, name,
+ ABSORB_GITDIR_RECURSE_SUBMODULES);
}
-
- error_removing_concrete_submodules(&files, &errs);
-
- return errs;
}
static int check_local_mod(struct object_id *head, int index_only)
@@ -120,7 +99,6 @@ static int check_local_mod(struct object_id *head, int index_only)
int errs = 0;
struct string_list files_staged = STRING_LIST_INIT_NODUP;
struct string_list files_cached = STRING_LIST_INIT_NODUP;
- struct string_list files_submodule = STRING_LIST_INIT_NODUP;
struct string_list files_local = STRING_LIST_INIT_NODUP;
no_head = is_null_oid(head);
@@ -218,13 +196,8 @@ static int check_local_mod(struct object_id *head, int index_only)
else if (!index_only) {
if (staged_changes)
string_list_append(&files_cached, name);
- if (local_changes) {
- if (S_ISGITLINK(ce->ce_mode) &&
- !submodule_uses_gitfile(name))
- string_list_append(&files_submodule, name);
- else
- string_list_append(&files_local, name);
- }
+ if (local_changes)
+ string_list_append(&files_local, name);
}
}
print_error_files(&files_staged,
@@ -246,8 +219,6 @@ static int check_local_mod(struct object_id *head, int index_only)
&errs);
string_list_clear(&files_cached, 0);
- error_removing_concrete_submodules(&files_submodule, &errs);
-
print_error_files(&files_local,
Q_("the following file has local modifications:",
"the following files have local modifications:",
@@ -341,6 +312,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
exit(0);
}
+ submodules_absorb_gitdir_if_needed(prefix);
+
/*
* If not forced, the file, the index and the HEAD (if exists)
* must match; but the file can already been removed, since
@@ -357,9 +330,6 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
oidclr(&oid);
if (check_local_mod(&oid, index_only))
exit(1);
- } else if (!index_only) {
- if (check_submodules_use_gitfiles())
- exit(1);
}
/*
@@ -393,27 +363,16 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
const char *path = list.entry[i].name;
if (list.entry[i].is_submodule) {
if (is_empty_dir(path)) {
- if (!rmdir(path)) {
- removed = 1;
- if (!remove_path_from_gitmodules(path))
- gitmodules_modified = 1;
- continue;
- }
- } else {
- strbuf_reset(&buf);
- strbuf_addstr(&buf, path);
- if (!remove_dir_recursively(&buf, 0)) {
- removed = 1;
- if (!remove_path_from_gitmodules(path))
- gitmodules_modified = 1;
- strbuf_release(&buf);
- continue;
- } else if (!file_exists(path))
- /* Submodule was removed by user */
- if (!remove_path_from_gitmodules(path))
- gitmodules_modified = 1;
- /* Fallthrough and let remove_path() fail. */
- }
+ if (rmdir(path))
+ die_errno("git rm: '%s'", path);
+ } else if (file_exists(path))
+ /* non empty directory: */
+ remove_directory_or_die(path);
+
+ removed = 1;
+ if (!remove_path_from_gitmodules(path))
+ gitmodules_modified = 1;
+ continue;
}
if (!remove_path(path)) {
removed = 1;
diff --git a/cache.h b/cache.h
index a50a61a197..3a423af59b 100644
--- a/cache.h
+++ b/cache.h
@@ -2018,4 +2018,6 @@ void sleep_millisec(int millisec);
*/
void safe_create_dir(const char *dir, int share);
+extern void remove_directory_or_die(const char *path);
+
#endif /* CACHE_H */
diff --git a/entry.c b/entry.c
index c6eea240b6..ddd4cfb2bf 100644
--- a/entry.c
+++ b/entry.c
@@ -73,6 +73,14 @@ static void remove_subtree(struct strbuf *path)
die_errno("cannot rmdir '%s'", path->buf);
}
+void remove_directory_or_die(const char *path)
+{
+ struct strbuf sb = STRBUF_INIT;
+ strbuf_addstr(&sb, path);
+ remove_subtree(&sb);
+ strbuf_release(&sb);
+}
+
static int create_file(const char *path, unsigned int mode)
{
mode = (mode & 0100) ? 0777 : 0666;
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index bcbb680651..5aa6db584c 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -569,26 +569,22 @@ test_expect_success 'rm of a conflicted unpopulated submodule succeeds' '
test_cmp expect actual
'
-test_expect_success 'rm of a populated submodule with a .git directory fails even when forced' '
+test_expect_success 'rm of a populated submodule with a .git directory migrates git dir' '
git checkout -f master &&
git reset --hard &&
git submodule update &&
(cd submod &&
rm .git &&
cp -R ../.git/modules/sub .git &&
- GIT_WORK_TREE=. git config --unset core.worktree
+ GIT_WORK_TREE=. git config --unset core.worktree &&
+ rm -r ../.git/modules/sub
) &&
- test_must_fail git rm submod &&
- test -d submod &&
- test -d submod/.git &&
- git status -s -uno --ignore-submodules=none >actual &&
- ! test -s actual &&
- test_must_fail git rm -f submod &&
- test -d submod &&
- test -d submod/.git &&
+ git rm submod 2>output.err &&
+ ! test -d submod &&
+ ! test -d submod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
- ! test -s actual &&
- rm -rf submod
+ test -s actual &&
+ test_i18ngrep Migrating output.err
'
cat >expect.deepmodified <<EOF
@@ -667,24 +663,19 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
git submodule update --recursive &&
(cd submod/subsubmod &&
rm .git &&
- cp -R ../../.git/modules/sub/modules/sub .git &&
+ mv ../../.git/modules/sub/modules/sub .git &&
GIT_WORK_TREE=. git config --unset core.worktree
) &&
- test_must_fail git rm submod &&
- test -d submod &&
- test -d submod/subsubmod/.git &&
- git status -s -uno --ignore-submodules=none >actual &&
- ! test -s actual &&
- test_must_fail git rm -f submod &&
- test -d submod &&
- test -d submod/subsubmod/.git &&
+ git rm submod 2>output.err &&
+ ! test -d submod &&
+ ! test -d submod/subsubmod/.git &&
git status -s -uno --ignore-submodules=none >actual &&
- ! test -s actual &&
- rm -rf submod
+ test -s actual &&
+ test_i18ngrep Migrating output.err
'
test_expect_success 'checking out a commit after submodule removal needs manual updates' '
- git commit -m "submodule removal" submod &&
+ git commit -m "submodule removal" submod .gitmodules &&
git checkout HEAD^ &&
git submodule update &&
git checkout -q HEAD^ &&
--
2.11.0.rc2.35.g26e18c9
^ permalink raw reply related
* Re: [PATCH v9 5/5] transport: add from_user parameter to is_transport_allowed
From: Jeff King @ 2016-12-14 22:52 UTC (permalink / raw)
To: Blake Burkhart; +Cc: git, jrnieder, Brandon Williams, gitster, sbeller
In-Reply-To: <CAP3OtXhH++szRws20MaHt-ftLBMUJuYiTmfL50mOFP4FA4Mn6Q@mail.gmail.com>
On Wed, Dec 14, 2016 at 04:29:52PM -0600, Blake Burkhart wrote:
> You may want to set CURLOPT_DEFAULT_PROTOCOL if we don't already. Apparently
> the default value of NULL causes it to make a guess based on the host if no
> protocol is present. But you are discussing a situation where "http://" is
> present, so that doesn't apply.
Cute. I agree it doesn't matter here, where we're sure there's a
protocol specifier at the beginning. It might matter if you instruct git
to use a specific remote-helper, like:
$ echo 127.0.0.1 ftp.example.com >>/etc/hosts
$ git clone http::ftp.example.com
which will try to connect via ftp. Of course that's no different than:
$ git clone http::ftp://example.com
which you can already do. git-clone sees "http::" and hands it off to
git-remote-http, which then processes the rest of the arguments as it
sees fit (in this case, handing it off to curl).
Prior to these more recent patches I suspect you could do:
$ git clone http::file://whatever
but now we set CURLOPT_PROTOCOL to restrict it to just http/ftp (so you
can be confusing by asking for http and ending up in curl to do ftp, but
in any such case you could also have just asked for ftp in the first
place).
> Also, I thought we left out ftp because it was deprecated, but I don't
> remember exactly.
I couldn't find anything interesting in the archives (neither the public
list nor git-security). Given how unlikely it is to be used, it does
seem like a good idea to keep it in the "maybe" category, if only
because it decreases the attack surface (and for those following along,
we're just talking about not-from-user uses here, so people sticking a
funny ftp URL in .gitmodules, or redirecting http to ftp, etc).
-Peff
^ permalink raw reply
* Re: [PATCHv3 3/4] submodule: add flags to ok_to_remove_submodule
From: Brandon Williams @ 2016-12-14 23:10 UTC (permalink / raw)
To: Stefan Beller; +Cc: gitster, git, David.Turner, sandals
In-Reply-To: <20161214224101.6211-4-sbeller@google.com>
On 12/14, Stefan Beller wrote:
> In different contexts the question whether deleting a submodule is ok
> to remove may be answered differently.
This sentence is oddly worded. Maybe this:
In different context the question "Is it ok to delete a submodule?"
may be answered differently.
--
Brandon Williams
^ permalink raw reply
* Re: [PATCH v10 0/6] transport protocol policy configuration
From: Junio C Hamano @ 2016-12-14 23:25 UTC (permalink / raw)
To: Brandon Williams; +Cc: git, peff, sbeller, bburky, jrnieder
In-Reply-To: <1481755195-174539-1-git-send-email-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
> v10 of this series fixes the following:
> * A few updates to the commit messages in order to better convey the reasoning
> behind the a few of the patches.
> * Additional test to verify that curl redirects respect configured protocol
> policies.
> * Patch added by Jeff King to make http alternates respect configured
> protocol policies.
Thanks. Will replace the previous one.
^ permalink raw reply
* Re: [PATCHv3 3/4] submodule: add flags to ok_to_remove_submodule
From: Junio C Hamano @ 2016-12-14 23:48 UTC (permalink / raw)
To: Stefan Beller; +Cc: git, David.Turner, bmwill, sandals
In-Reply-To: <20161214224101.6211-4-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
> diff --git a/submodule.c b/submodule.c
> index 9f0b544ebe..2d13744b06 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1019,7 +1019,7 @@ int submodule_uses_gitfile(const char *path)
> return 1;
> }
>
> -int ok_to_remove_submodule(const char *path)
> +int ok_to_remove_submodule(const char *path, unsigned flags)
> {
> ssize_t len;
> struct child_process cp = CHILD_PROCESS_INIT;
> @@ -1032,15 +1032,27 @@ int ok_to_remove_submodule(const char *path)
> if (!submodule_uses_gitfile(path))
> return 0;
>
> - argv_array_pushl(&cp.args, "status", "--porcelain", "-u",
> + argv_array_pushl(&cp.args, "status", "--porcelain",
> "--ignore-submodules=none", NULL);
> +
> + if (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED)
> + argv_array_push(&cp.args, "-uno");
> + else
> + argv_array_push(&cp.args, "-uall");
> +
> + if (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED))
> + argv_array_push(&cp.args, "--ignored");
> +
These "internal values to assemble command line" operations we
cannot avoid. But things like this ...
> if (start_command(&cp))
> - die(_("could not run 'git status --porcelain -u --ignore-submodules=none' in submodule %s"), path);
> + die(_("could not run 'git status --porcelain --ignore-submodules=none %s %s' in submodule '%s'"),
> + (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED) ? "-uno" : "-uall",
> + (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)) ? "--ignored" : "",
> + path);
and this ...
> if (finish_command(&cp))
> - die(_("'git status --porcelain -u --ignore-submodules=none' failed in submodule %s"), path);
> + die(_("'git status --porcelain --ignore-submodules=none %s %s' failed in submodule '%s'"),
> + (flags & SUBMODULE_REMOVAL_IGNORE_UNTRACKED) ? "-uno" : "-uall",
> + (!(flags & SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED)) ? "--ignored" : "",
> + path);
makes me wonder if we want a helper that builds the string out of an
already assembled cp.args[] array, so that we won't have to do the
same thing twice/thrice and more importantly we won't have to worry
about these three going out of sync.
^ permalink raw reply
* Re: [PATCHv3 4/4] rm: add absorb a submodules git dir before deletion
From: Junio C Hamano @ 2016-12-14 23:55 UTC (permalink / raw)
To: Stefan Beller; +Cc: git, David.Turner, bmwill, sandals
In-Reply-To: <20161214224101.6211-5-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
> if (list.entry[i].is_submodule) {
> if (is_empty_dir(path)) {
> + if (rmdir(path))
> + die_errno("git rm: '%s'", path);
> + } else if (file_exists(path))
> + /* non empty directory: */
Lose colon?
> + remove_directory_or_die(path);
... otherwise? I.e.
else
???
If we are running "git rm -f <path>", then the path could be a
submodule in the index and on the filesystem, it could be (1)
already missing, as the user removed an empty submodule directory
she is not interested in, (2) a non-directory, e.g. a file or a
symbolic link, perhaps because she was trying to reorganize the
superproject working tree but decided against it, or (3) something
else?
(1) is perfectly OK; we end up with a result without the path, which
is what "git rm -f" wanted to do anyway. I am not sure what should
happen in (2), and what other corner cases there are for (3), though.
And use of file_exists(path) in the above patch may trigger a
strange error message in case (2), as remove_directory_or_die()
would say "path is not a directory", to which the user will say "Yes
I know, I wanted you to remove it with 'git rm -f'".
^ permalink raw reply
* Re: [PATCH v10 2/6] http: always warn if libcurl version is too old
From: Jeff King @ 2016-12-15 0:21 UTC (permalink / raw)
To: Brandon Williams; +Cc: git, gitster, sbeller, bburky, jrnieder
In-Reply-To: <1481755195-174539-3-git-send-email-bmwill@google.com>
On Wed, Dec 14, 2016 at 02:39:51PM -0800, Brandon Williams wrote:
> Always warn if libcurl version is too old because:
>
> 1. Even without a protocol whitelist, newer versions of curl have all
> non-http protocols disabled by default.
Technically, non-http and non-ftp. Maybe just "non-standard" would be
more accurate.
Not worth a re-roll, but if Junio hasn't applied yet, maybe worth fixing
up while applying.
-Peff
^ permalink raw reply
* Re: [PATCH v10 0/6] transport protocol policy configuration
From: Jeff King @ 2016-12-15 0:22 UTC (permalink / raw)
To: Brandon Williams; +Cc: git, gitster, sbeller, bburky, jrnieder
In-Reply-To: <1481755195-174539-1-git-send-email-bmwill@google.com>
On Wed, Dec 14, 2016 at 02:39:49PM -0800, Brandon Williams wrote:
> v10 of this series fixes the following:
> * A few updates to the commit messages in order to better convey the reasoning
> behind the a few of the patches.
> * Additional test to verify that curl redirects respect configured protocol
> policies.
> * Patch added by Jeff King to make http alternates respect configured
> protocol policies.
Thanks, this one looks fine to me.
-Peff
^ permalink raw reply
* git bug - merging JS / Node.js code with "git merge --squash"
From: Alexander Mills @ 2016-12-15 7:12 UTC (permalink / raw)
To: git
@git-community
I am on Git git version 2.7.4
This problem is happening on Ubuntu 16.04, but the same problem was
also happening when I was running on MacOS.
I am consistently seeing merge bugs, when merging between branches of
a mostly Node.js project.
I am seeing fairly bad merges that mangle the code in ways that seem
to clearly show some sort of Git bug. Some of these merges were for
files where there was likely not even a diff between the files.
TBH I am no Git expert, but maybe I will learn something from this
investigation.
The latest example of a mangled file is here:
https://github.com/ORESoftware/suman/blob/staging/suman.conf.js
You can see some repeat code, and also there is a dangling brace which
means that the file won't even "compile" with Node.js, using "$ node
-c". Notice that this file was *not* a file where I recently had to
manually merge code or manually fix a conflict, so I am hoping this is
not obvious operator error.
Here is the script I am using to merge between branches:
https://github.com/ORESoftware/suman/blob/dev/publish-suman.sh
basically it is doing the merge with this line:
git merge --squash -Xtheirs dev -m "squashing" &&
This is obviously very concerning because I can get very strange bugs
that I wouldn't expect, because I just assume that merges go well if
they succeed and it's hard to check for failure after that; even in a
compile statically typed language it could still prove difficult.
I am doing a check to make sure all my files compile with "node -c"
after the merge, but even then Git could create mangled code that
would still pass a "node -c" check.
Please let me know if this is a known bug and if there is a good
strategy to avoid it.
thanks!
--
Alexander D. Mills
(650)269-9502
alexander.d.mills@gmail.com
www.linkedin.com/pub/alexander-mills/b/7a5/418/
^ permalink raw reply
* Re: [PATCHv3 1/3] merge: Add '--continue' option as a synonym for 'git commit'
From: Chris Packham @ 2016-12-15 7:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: GIT, Markus Hitter, Jeff King, Jacob Keller
In-Reply-To: <xmqqk2b2xu81.fsf@gitster.mtv.corp.google.com>
On Thu, Dec 15, 2016 at 7:04 AM, Junio C Hamano <gitster@pobox.com> wrote:
> The last one 3/3 is a nice touch that makes sure that we do not
> forget what we discovered during the discussion. Very much
> appreciated.
>
> Will queue. Thanks.
Did you want me to send a v4 to mark the strings for translation or
will you apply a fixup your end?
^ permalink raw reply
* Re: [PATCH v2] fix pushing to //server/share/dir on Windows
From: Torsten Bögershausen @ 2016-12-15 7:30 UTC (permalink / raw)
To: Johannes Sixt, Jeff King; +Cc: Johannes Schindelin, Git Mailing List
In-Reply-To: <787a421b-8b7a-14c5-768f-06c3dc183cf4@kdbg.org>
On 14/12/16 20:37, Johannes Sixt wrote:
> normalize_path_copy() is not prepared to keep the double-slash of a
> //server/share/dir kind of path, but treats it like a regular POSIX
> style path and transforms it to /server/share/dir.
>
> The bug manifests when 'git push //server/share/dir master' is run,
> because tmp_objdir_add_as_alternate() uses the path in normalized
> form when it registers the quarantine object database via
> link_alt_odb_entries(). Needless to say that the directory cannot be
> accessed using the wrongly normalized path.
>
> Fix it by skipping all of the root part, not just a potential drive
> prefix. offset_1st_component takes care of this, see the
> implementation in compat/mingw.c::mingw_offset_1st_component().
>
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ---
> Am 14.12.2016 um 18:30 schrieb Jeff King:
>> Would it be reasonable to
>> write:
>>
>> /* Copy initial part of absolute path, converting separators on Windows */
>> const char *end = src + offset_1st_component(src);
>> while (src < end) {
>> char c = *src++;
>> if (c == '\\')
>> c = '/';
>> *dst++ = c;
>> }
> Makes a lot of sense! I haven't had an opportunity, though, to test
> on Windows.
I'm not sure, if a conversion should be done here, in this part of code.
To my knowledge,
C:\dir1\file
is the same
as
C:/dir1/file
and that is handled by windows.
The \\server\share\dir1\file is native to windows,
and I can't see good reasons to change '\' into '/' somewhere in Git,
when UNC is used.
Cygwin does a translation from
//server/share/dir1/file
into
\\server\share\dir1\file
In other words:
The patch looks good as is, and once I get a Windows machine,
may be able to do some testing and come up with test cases
<https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx>
[]
^ permalink raw reply
* Cherry-pick applied X times
From: Delanoe, Yann @ 2016-12-15 8:12 UTC (permalink / raw)
To: git@vger.kernel.org
Hi Git community,
I'm new to GIT and responsible of a project to migrate our SVN repo to GIT.
I've made the migration with the git-svn tools ... it was long, but everything seems fine ; source code is correct and all its history is there.
It happen with our delivery workflow that we will have to use cherry-picks to prepare our patches, so I made some test on it.
During those tests I saw a strange behaviour: I tried to cherry-pick onto a release branch a commit from the master that had been previously already merged onto this branch with SVN. GIT did not detect it and added the code a second time in the source file modified. I supposed this was du the fact the first merge had been made with SVN. I tried to cherry pick the same commit again ... and GIT add one more time the code of the commit. It appears I could cherry-pick this commit X times with GIT, and each time he added the code again.
I looked in SVN, the merge property of the first commit from master to the release branch is ok.
Our SVN repo has more than 22K revisions
I found out that some other commits had the same behaviour.
Is there a direction onto which I should investigate to determine where the problem comes from ?
Here is an example of the multiple cherry pick.
Branches:
> git branch
master
* release/15.0.0
release/15.3.0
Check commit already exist on release (cb8c480) and get master hash (bee110c):
> git log --oneline |grep GTX-20264
cb8c480 GTX-20264 : Missing end of string in field hostReference for custom network ack
> git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
> git log --oneline |grep GTX-20264
bee110c GTX-20264 : Missing end of string in field hostReference for custom network ack
> git checkout release/15.0.0
Switched to branch 'release/15.0.0'
Your branch is up-to-date with 'origin/release/15.0.0'.
And now I cherry-pick the master commit onto the release/15.0.0 a multiple of times:
> git cherry-pick bee110c
[release/15.0.0 e8bfc33] GTX-20264 : Missing end of string in field hostReference for custom network ack
Author: Yann Delanoe <ydelanoe@bottomline.com>
1 file changed, 3 insertions(+)
> git cherry-pick bee110c
[release/15.0.0 2b98c8d] GTX-20264 : Missing end of string in field hostReference for custom network ack
Author: Yann Delanoe <ydelanoe@bottomline.com>
1 file changed, 3 insertions(+)
> git cherry-pick bee110c
[release/15.0.0 820cd8a] GTX-20264 : Missing end of string in field hostReference for custom network ack
Author: Yann Delanoe <ydelanoe@bottomline.com>
1 file changed, 3 insertions(+)
Best regards
Yann DELANOE - Product engineer - Bottomline technologies
^ permalink raw reply
* Re: [PATCH v2 3/6] update_unicode.sh: pin the uniset repo to a known good commit
From: Dennis Kaarsemaker @ 2016-12-15 9:47 UTC (permalink / raw)
To: Beat Bolli, git
In-Reply-To: <1481671904-1143-4-git-send-email-dev+git@drbeat.li>
On Wed, 2016-12-14 at 00:31 +0100, Beat Bolli wrote:
> + ( cd uniset && git checkout 4b186196dd )
Micronit, but this is perhaps better written as
git -C uniset checkout 4b186196dd
to avoid the subshell and cd.
D.
^ permalink raw reply
* Re: [RFC/PATCH v3 00/16] Add initial experimental external ODB support
From: Christian Couder @ 2016-12-15 9:56 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jeff King, Nguyen Thai Ngoc Duy, Mike Hommey, Lars Schneider,
Eric Wong, Christian Couder
In-Reply-To: <xmqqshpr1tox.fsf@gitster.mtv.corp.google.com>
On Tue, Dec 13, 2016 at 9:05 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Christian Couder <christian.couder@gmail.com> writes:
>
>> In general I think that having a lot of refs is really a big problem
>> right now in Git as many big organizations using Git are facing this
>> problem in one form or another.
>> So I think that support for a big number of refs is a separate and
>> important problem that should and hopefully will be solved.
>
> But you do not have to make it worse.
>
> Is "refs" a good match for the problem you are solving? Or is it
> merely an expedient thing to use? I think it is the latter, judging
> by your mentioning RefTree. Whatever mechanism we choose, that will
> be carved into stone in users' repositories and you'd end up having
> to support it, and devise the migration path out of it if the initial
> selection is too problematic.
>
> That is why people (not just me) pointed out upfront that using refs
> for this purose would not scale.
What I should perhaps have clarified in my previous answer, and also
in the documentation of the patch series, is that in what I have done
and what I propose, the external odb helper is responsible for using
and creating the refs in refs/odbs/<odbname>/.
So this helper is free to just create one ref, as it is also free to
create many refs. Git is just transmitting the refs that have been
created by this helper.
Right now people are already free to use whatever external script or
software to create whatever refs/stuff/* they want, pointing to
whatever objects they want, and have Git transmit that. And indeed I
know that it is already a problem out there, as then people often get
into trouble related to having many refs. But it is a different
problem that is not going to be solved anyway in this patch series.
So if some people want to use a specific external odb, it's their
responsibility to use an helper that will not create too many refs.
If they know that they just need their external odb to handle around
10 big files, why wouldn't they use a simple helper that creates one
odb ref per big file/blob?
On the contrary if they know that they will need to handle thousands
of big files, then, yeah, they should find or implement a helper that
will, as I suggested in my previous email, just create one ref
in refs/odbs/<odbname>/ that points to a blob that contains a list
(maybe a json list with information attached to each item) of the
blobs stored in the external odb.
For testing purposes in what I have done in the patch series, I use
only simple helpers that create one odb ref per big file/blob. So yes,
it gives a bad example, because, if people just copy this design while
they need the e-odb to handle a big number of files, then they will be
in trouble. But this does not by itself carve anything into stone.
One thing that could help is perhaps to put big warnings into the
simple helpers saying "Be careful!!! This will not scale if you want
to handle more than a small number of large files!!! You'd better use
an helper that does <this and that> if you want to handle many large
files!!! You have been warned!!!".
So I am reluctant at this point to write a complex helper just for the
purpose of showing a good example to people who want to use e-odb to
store a big number of files, as these people anyway would probably
need something like Lars' "filter process protocol" too.
^ permalink raw reply
* Re: [PATCH v2] fix pushing to //server/share/dir on Windows
From: Jeff King @ 2016-12-15 11:01 UTC (permalink / raw)
To: Torsten Bögershausen
Cc: Johannes Sixt, Johannes Schindelin, Git Mailing List
In-Reply-To: <c8501e28-db8a-5b6e-717c-5bda1e63c2e7@web.de>
On Thu, Dec 15, 2016 at 08:30:52AM +0100, Torsten Bögershausen wrote:
> > > Would it be reasonable to
> > > write:
> > >
> > > /* Copy initial part of absolute path, converting separators on Windows */
> > > const char *end = src + offset_1st_component(src);
> > > while (src < end) {
> > > char c = *src++;
> > > if (c == '\\')
> > > c = '/';
> > > *dst++ = c;
> > > }
> > Makes a lot of sense! I haven't had an opportunity, though, to test
> > on Windows.
> I'm not sure, if a conversion should be done here, in this part of code.
> To my knowledge,
>
> C:\dir1\file
> is the same
> as
> C:/dir1/file
> and that is handled by windows.
I don't have an opinion either way on what Windows would want, but note
that the function already _does_ convert separators to slashes. With
Johannes's original patch, you'd end up with a mix, like:
\\server\share/dir1/file
So this conversion is really just retaining the original behavior, and
making it consistent throughout the path.
Which isn't to say that the function as it currently exists isn't a
little bit buggy. :)
One of the points of normalizing, though, is that Git can then do
textual comparisons between the output. So I think there's value in
having a canonical internal representation, even if the OS could handle
more exotic ones.
-Peff
^ permalink raw reply
* [PATCH 1/6] Enable ability to visualise the results of git cherry C1 C2
From: Pierre Dumuid @ 2016-12-15 11:28 UTC (permalink / raw)
To: paulus, git; +Cc: Pierre Dumuid
It's a bit clunky but it works!!
Usage:
- mark commit one (e.g. v45)
- Select commit two.
- Switch the gdttype to the option, "git-cherry between marked commit and:"
Signed-off-by: Pierre Dumuid <pmdumuid@gmail.com>
---
gitk | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 107 insertions(+), 3 deletions(-)
diff --git a/gitk b/gitk
index a14d7a1..50d1ef4 100755
--- a/gitk
+++ b/gitk
@@ -2319,7 +2319,9 @@ proc makewindow {} {
[mc "containing:"] \
[mc "touching paths:"] \
[mc "adding/removing string:"] \
- [mc "changing lines matching:"]]
+ [mc "changing lines matching:"] \
+ [mc "git-cherry between marked commit and:"] \
+ ]
trace add variable gdttype write gdttype_change
pack .tf.lbar.gdttype -side left -fill y
@@ -4707,6 +4709,18 @@ proc gdttype_change {name ix op} {
global gdttype highlight_files findstring findpattern
stopfinding
+
+ if {$gdttype eq [mc "git-cherry between marked commit and:"]} {
+ if {$highlight_files ne {}} {
+ set highlight_files {}
+ hfiles_change
+ }
+ findcom_change
+ update_gitcherrylist
+ drawvisible
+ return
+ }
+
if {$findstring ne {}} {
if {$gdttype eq [mc "containing:"]} {
if {$highlight_files ne {}} {
@@ -4733,6 +4747,9 @@ proc find_change {name ix op} {
stopfinding
if {$gdttype eq [mc "containing:"]} {
findcom_change
+ } elseif {$gdttype eq [mc "git-cherry between marked commit and:"]} {
+ findcom_change
+ update_gitcherrylist
} else {
if {$highlight_files ne $findstring} {
set highlight_files $findstring
@@ -4742,6 +4759,54 @@ proc find_change {name ix op} {
drawvisible
}
+proc update_gitcherrylist {} {
+ global gitcherryids
+ global markedid
+ global findstring
+ global fstring
+ global currentid
+ global iddrawn
+
+ unset -nocomplain gitcherryids
+ set fs $findstring
+
+ if {$findstring eq {}} {
+ $fstring delete 0 end
+ $fstring insert 0 $currentid
+ }
+
+ if {![info exists markedid]} {
+ error_popup [mc "Please mark a git commit before using this find method!"]
+ return
+ }
+
+ #puts [join [list "Running cherry between: `" $markedid "` and `" $findstring "`"] ""]
+
+ if {[catch {set cherryOutput [exec git cherry $markedid $findstring]}]} {
+ puts "ERROR: An error occured running git-cherry!"
+ return
+ }
+
+ set cherryLines [split $cherryOutput "\n"]
+ foreach cherryLine $cherryLines {
+ set op [lindex [split $cherryLine " "] 0]
+ set gitSha [lindex [split $cherryLine " "] 1]
+
+ #puts [join [list "line is: `" $cherryLine "`, op:`" $op "`, gitSha:`" $gitSha "`"] ""]
+ if {$op eq "+"} {
+ set gitcherryids($gitSha) 1
+ if ([info exists iddrawn($gitSha)]) {
+ bolden $gitSha mainfontbold
+ }
+
+ }
+ }
+ # puts "list is as follows"
+ #foreach {gitsha setBold} [array get gitcherryids] {
+ # puts [concat $gitsha = $setBold]
+ #}
+}
+
proc findcom_change args {
global nhighlights boldnameids
global findpattern findtype findstring gdttype
@@ -4802,6 +4867,9 @@ proc do_file_hl {serial} {
set gdtargs [list "-S$highlight_files"]
} elseif {$gdttype eq [mc "changing lines matching:"]} {
set gdtargs [list "-G$highlight_files"]
+ } elseif {$gdttype eq [mc "git-cherry between marked commit and:"]} {
+ # Skipping opening the file handle, filehighlight
+ return
} else {
# must be "containing:", i.e. we're searching commit info
return
@@ -4882,6 +4950,17 @@ proc doesmatch {f} {
}
}
+proc askcherryhighlight {row id} {
+ global nhighlights gitcherryids
+
+ set isbold 0
+ if {[info exists gitcherryids($id)]} {
+ set isbold 1
+ }
+
+ set nhighlights($id) $isbold
+}
+
proc askfindhighlight {row id} {
global nhighlights commitinfo iddrawn
global findloc
@@ -6216,6 +6295,7 @@ proc drawcmitrow {row} {
global filehighlight fhighlights findpattern nhighlights
global hlview vhighlights
global highlight_related rhighlights
+ global gdttype
if {$row >= $numcommits} return
@@ -6226,6 +6306,11 @@ proc drawcmitrow {row} {
if {[info exists filehighlight] && ![info exists fhighlights($id)]} {
askfilehighlight $row $id
}
+
+ if {$gdttype eq [mc "git-cherry between marked commit and:"] && ![info exists nhighlights($id)]} {
+ askcherryhighlight $row $id
+ }
+
if {$findpattern ne {} && ![info exists nhighlights($id)]} {
askfindhighlight $row $id
}
@@ -6776,7 +6861,9 @@ proc dofind {{dirn 1} {wrap 1}} {
}
set findcurline $findstartline
nowbusy finding [mc "Searching"]
- if {$gdttype ne [mc "containing:"] && ![info exists filehighlight]} {
+ if {$gdttype eq [mc "git-cherry between marked commit and:"]} {
+ # Don't do anything related to open do_file_hl since we'll just have a list
+ } elseif {$gdttype ne [mc "containing:"] && ![info exists filehighlight]} {
after cancel do_file_hl $fh_serial
do_file_hl $fh_serial
}
@@ -6803,6 +6890,7 @@ proc findmore {} {
global findstartline findcurline findallowwrap
global find_dirn gdttype fhighlights fprogcoord
global curview varcorder vrownum varccommits vrowmod
+ global gitcherryids
if {![info exists find_dirn]} {
return 0
@@ -6848,7 +6936,23 @@ proc findmore {} {
set arow [lindex $vrownum($curview) $ai]
set ids [lindex $varccommits($curview,$a)]
set arowend [expr {$arow + [llength $ids]}]
- if {$gdttype eq [mc "containing:"]} {
+
+ if {$gdttype eq [mc "git-cherry between marked commit and:"]} {
+ for {} {$n > 0} {incr n -1; incr l $find_dirn} {
+ if {$l < $arow || $l >= $arowend} {
+ incr ai $find_dirn
+ set a [lindex $varcorder($curview) $ai]
+ set arow [lindex $vrownum($curview) $ai]
+ set ids [lindex $varccommits($curview,$a)]
+ set arowend [expr {$arow + [llength $ids]}]
+ }
+ set id [lindex $ids [expr {$l - $arow}]]
+ if {[info exists gitcherryids($id)]} {
+ set found 1
+ }
+ if {$found} break
+ }
+ } elseif {$gdttype eq [mc "containing:"]} {
for {} {$n > 0} {incr n -1; incr l $find_dirn} {
if {$l < $arow || $l >= $arowend} {
incr ai $find_dirn
--
2.10.2
^ permalink raw reply related
* [PATCH 2/6] Add ability to follow a remote branch with a dialog
From: Pierre Dumuid @ 2016-12-15 11:28 UTC (permalink / raw)
To: paulus, git; +Cc: Pierre Dumuid
In-Reply-To: <20161215112847.14719-1-pmdumuid@gmail.com>
A suggested name is provided when creating a new "following" branch.
Signed-off-by: Pierre Dumuid <pmdumuid@gmail.com>
---
gitk | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 82 insertions(+), 4 deletions(-)
diff --git a/gitk b/gitk
index 50d1ef4..36cba49 100755
--- a/gitk
+++ b/gitk
@@ -2673,6 +2673,7 @@ proc makewindow {} {
{mc "Rename this branch" command mvbranch}
{mc "Remove this branch" command rmbranch}
{mc "Copy branch name" command {clipboard clear; clipboard append $headmenuhead}}
+ {mc "Follow this branch" command follow_remote_branch_dialog}
}
$headctxmenu configure -tearoff 0
@@ -9947,23 +9948,100 @@ proc headmenu {x y id head} {
stopfinding
set headmenuid $id
set headmenuhead $head
- array set state {0 normal 1 normal 2 normal}
+ array set state {0 normal 1 normal 2 normal 3 normal}
if {[string match "remotes/*" $head]} {
set localhead [string range $head [expr [string last / $head] + 1] end]
if {[info exists headids($localhead)]} {
set state(0) disabled
}
- array set state {1 disabled 2 disabled}
+ array set state {1 disabled 2 disabled 3 normal}
}
if {$head eq $mainhead} {
- array set state {0 disabled 2 disabled}
+ array set state {0 disabled 2 disabled 3 disabled}
+ } else {
+ set state(3) disabled
}
- foreach i {0 1 2} {
+ foreach i {0 1 2 3} {
$headctxmenu entryconfigure $i -state $state($i)
}
tk_popup $headctxmenu $x $y
}
+proc follow_remote_branch_dialog {} {
+ global headmenuhead NS
+
+ # check the tree is clean first??
+ nowbusy createFollowingBranch [mc "Creating following branch"]
+ update
+ dohidelocalchanges
+
+ set top .create_following_branch
+ catch {destroy $top}
+ ttk_toplevel $top
+ make_transient $top .
+
+ ${NS}::label $top.title -text [mc "Create following branch"]
+ grid $top.title - -pady 10
+
+ ${NS}::label $top.remote_branch_name_label -text [mc "Remote Branch:"]
+ ${NS}::entry $top.remote_branch_name -width 40
+ $top.remote_branch_name insert 0 $headmenuhead
+ $top.remote_branch_name conf -state readonly
+ grid $top.remote_branch_name_label $top.remote_branch_name -sticky w
+
+ ${NS}::label $top.new_branch_name_label -text [mc "Name:"]
+ ${NS}::entry $top.new_branch_name -width 40
+ set suggested_name $headmenuhead
+ regsub {^remotes/[^/]*/} $suggested_name {} suggested_name
+ $top.new_branch_name insert 0 $suggested_name
+ grid $top.new_branch_name_label $top.new_branch_name -sticky w
+
+ set actionCreate [list follow_remote_branch_callback $top]
+ set actionCancel "catch {notbusy createFollowingBranch; destroy $top}"
+
+ ${NS}::frame $top.buts
+ ${NS}::button $top.buts.go -text [mc "Create"] -command $actionCreate
+ ${NS}::button $top.buts.can -text [mc "Cancel"] -command $actionCancel
+ grid $top.buts.go $top.buts.can
+ grid columnconfigure $top.buts 0 -weight 1 -uniform a
+ grid columnconfigure $top.buts 1 -weight 1 -uniform a
+ grid $top.buts - -pady 10 -sticky ew
+
+ bind $top <Key-Return> $actionCreate
+ bind $top <Key-Escape> $actionCancel
+
+ focus $top.new_branch_name
+}
+
+proc follow_remote_branch_callback {top} {
+ global headids idheads NS
+ set new_branch_name [$top.new_branch_name get]
+ set remote_branch_name [$top.remote_branch_name get]
+ set cmdargs {}
+
+ if {$new_branch_name eq {}} {
+ error_popup [mc "Please specify a name for the new branch"] $top
+ return
+ }
+ if {[info exists headids($new_branch_name)]} {
+ error_popup [mc "The branch name you specified already exists, please specify a new name"] $top
+ return
+ }
+ catch {destroy $top}
+
+ lappend cmdargs $new_branch_name $remote_branch_name
+
+ if {[catch {
+ eval exec git branch --track $cmdargs
+ } err]} {
+ notbusy createFollowingBranch
+ error_popup $err
+ } else {
+ notbusy createFollowingBranch
+ updatecommits
+ }
+}
+
proc cobranch {} {
global headmenuid headmenuhead headids
global showlocalchanges
--
2.10.2
^ permalink raw reply related
* [PATCH 3/6] Add a tree view to the local branches, remote branches and tags, where / is treated as a directory seperator.
From: Pierre Dumuid @ 2016-12-15 11:28 UTC (permalink / raw)
To: paulus, git; +Cc: Pierre Dumuid
In-Reply-To: <20161215112847.14719-1-pmdumuid@gmail.com>
Signed-off-by: Pierre Dumuid <pmdumuid@gmail.com>
---
gitk | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 117 insertions(+)
diff --git a/gitk b/gitk
index 36cba49..a894f1d 100755
--- a/gitk
+++ b/gitk
@@ -2089,6 +2089,10 @@ proc makewindow {} {
{mc "Reread re&ferences" command rereadrefs}
{mc "&List references" command showrefs -accelerator F2}
{xx "" separator}
+ {mc "List Local Branches" command {show_tree_of_references_dialog "localBranches"} -accelerator F6}
+ {mc "List Remote Branches" command {show_tree_of_references_dialog "remoteBranches"} -accelerator F7}
+ {mc "List Tags" command {show_tree_of_references_dialog "tags"} -accelerator F8}
+ {xx "" separator}
{mc "Start git &gui" command {exec git gui &}}
{xx "" separator}
{mc "&Quit" command doquit -accelerator Meta1-Q}
@@ -2601,6 +2605,9 @@ proc makewindow {} {
bind . <F5> updatecommits
bindmodfunctionkey Shift 5 reloadcommits
bind . <F2> showrefs
+ bind . <F6> {show_tree_of_references_dialog "localBranches"}
+ bind . <F7> {show_tree_of_references_dialog "remoteBranches"}
+ bind . <F8> {show_tree_of_references_dialog "tags"}
bindmodfunctionkey Shift 4 {newview 0}
bind . <F4> edit_or_newview
bind . <$M1B-q> doquit
@@ -10146,6 +10153,116 @@ proc rmbranch {} {
run refill_reflist
}
+# Display a tree view of local branches, remote branches, and tags according to view_type.
+#
+# @param string view_type
+# Must be one of "localBranches", "remoteBranches", or "tags".
+#
+proc show_tree_of_references_dialog {view_type} {
+ global NS
+ global treefilelist
+ global headids tagids
+
+ switch -- $view_type {
+ "localBranches" {
+ set dialogName "Local Branches"
+ set top .show_tree_of_local_branches
+ set listOfReferences [lsort [array names headids -regexp {^(?!remotes/)} ]]
+ set truncateFrom 0
+ }
+ "remoteBranches" {
+ set dialogName "Remote Branches"
+ set top .show_tree_of_remote_branches
+ set listOfReferences [lsort [array names headids -regexp {^remotes/} ]]
+ set truncateFrom 8
+ }
+ "tags" {
+ set dialogName "Tags"
+ set top .show_tree_of_tags
+ set listOfReferences [lsort [array names tagids]]
+ set truncateFrom 0
+ }
+ }
+
+ if {[winfo exists $top]} {
+ raise $top
+ return
+ }
+
+ ttk_toplevel $top
+ wm title $top [mc "$dialogName: %s" [file tail [pwd]]]
+ wm geometry $top "600x900"
+
+ make_transient $top .
+
+ ## See http://www.tkdocs.com/tutorial/tree.html
+ ttk::treeview $top.referenceList -xscrollcommand "$top.horizontalScrollBar set" -yscrollcommand "$top.verticalScrollBar set"
+
+ # Populate the dialog
+ foreach reference $listOfReferences {
+ # The display name omits some leading characters (such as "remotes/")
+ set referenceDisplayName [string range $reference $truncateFrom end]
+
+ # Split the branch/tag by slashes, and incrementally ensure that each leaf in the treeview exists..
+ # otherwise add it.
+ set treeLeaves [split $referenceDisplayName "/"]
+ for {set i 0} {$i < [llength $treeLeaves]} {} {
+ set leafReferenceId [join [lrange $treeLeaves 0 $i] "/"]
+ if {![$top.referenceList exists $leafReferenceId]} {
+ if {$i > 0} {
+ set parentLeafId [join [lrange $treeLeaves 0 $i-1] "/"]
+ } else {
+ set parentLeafId {}
+ }
+ $top.referenceList insert $parentLeafId end -id $leafReferenceId -text [lindex $treeLeaves $i]
+ }
+ incr i
+ }
+ }
+
+ ${NS}::scrollbar $top.verticalScrollBar -command "$top.referenceList yview" -orient vertical
+ ${NS}::scrollbar $top.horizontalScrollBar -command "$top.referenceList xview" -orient horizontal
+
+ grid $top.referenceList $top.verticalScrollBar -sticky nsew
+ grid $top.horizontalScrollBar x -sticky ew
+
+ bind $top <Key-Escape> [list destroy $top]
+
+ bind $top.referenceList <<TreeviewSelect>> {callback_tree_of_references_item_selected %W; break}
+
+ grid columnconfigure $top 0 -weight 1
+ grid rowconfigure $top 0 -weight 1
+}
+
+# Call back for selecting a branch / tag in the tree of references
+#
+# @param w
+#
+proc callback_tree_of_references_item_selected {w} {
+ global headids tagids
+
+ set itemId [$w focus]
+ switch -- $w {
+ ".show_tree_of_local_branches.referenceList" {
+ if {[info exists headids($itemId)]} {
+ selbyid $headids($itemId)
+ }
+ }
+ ".show_tree_of_remote_branches.referenceList" {
+ set itemId "remotes/$itemId"
+ if {[info exists headids($itemId)]} {
+ selbyid $headids($itemId)
+ }
+ }
+ ".show_tree_of_tags.referenceList" {
+ if {[info exists tagids($itemId)]} {
+ selbyid $tagids($itemId)
+ }
+ }
+ }
+}
+
+
# Display a list of tags and heads
proc showrefs {} {
global showrefstop bgcolor fgcolor selectbgcolor NS
--
2.10.2
^ permalink raw reply related
* [PATCH 5/6] gitk: Add a "Save file as" menu item
From: Pierre Dumuid @ 2016-12-15 11:28 UTC (permalink / raw)
To: paulus, git; +Cc: Pierre Dumuid, Andreas Amann
In-Reply-To: <20161215112847.14719-1-pmdumuid@gmail.com>
Previously, there was no easy way to save a particular file from the
currently selected revision.
This patch adds a menu item "Save file as" to the file list popup
menu, which opens a file selection dialog to determine the name under
which a file should be saved. The default filename is of the form
"[shortid] basename". If the current revision is the index, the
default pattern is of the form "[index] basename". This works for
both, the "Patch" and "Tree" view. The menu item is disabled for the
"local uncommitted changes" fake revision.
Signed-off-by: Andreas Amann <andreas.amann@web.de>
Signed-off-by: Pierre Dumuid <pmdumuid@gmail.com>
---
gitk | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/gitk b/gitk
index 5f27716..0903d2d 100755
--- a/gitk
+++ b/gitk
@@ -2693,6 +2693,7 @@ proc makewindow {} {
{mc "Highlight this too" command {flist_hl 0}}
{mc "Highlight this only" command {flist_hl 1}}
{mc "External diff" command {external_diff}}
+ {mc "Save file as" command {save_file_as}}
{mc "Blame parent commit" command {external_blame 1}}
{mc "Copy path" command {clipboard clear; clipboard append $flist_menu_file}}
}
@@ -3504,6 +3505,7 @@ proc sel_flist {w x y} {
proc pop_flist_menu {w X Y x y} {
global ctext cflist cmitmode flist_menu flist_menu_file
global treediffs diffids
+ global nullid
stopfinding
set l [lindex [split [$w index "@$x,$y"] "."] 0]
@@ -3521,6 +3523,12 @@ proc pop_flist_menu {w X Y x y} {
}
# Disable "External diff" item in tree mode
$flist_menu entryconf 2 -state $xdiffstate
+ set savefilestate "normal"
+ if {[lindex $diffids 0] eq $nullid} {
+ set savefilestate "disabled"
+ }
+ # Disable "Save file as" item "local uncommited changes" revision
+ $flist_menu entryconf 3 -state $savefilestate
tk_popup $flist_menu $X $Y
}
@@ -3632,6 +3640,34 @@ proc external_diff_get_one_file {diffid filename diffdir} {
"revision $diffid"]
}
+proc save_file_as {} {
+ global nullid nullid2
+ global flist_menu_file cmitmode
+ global diffids
+
+ set diffid [lindex $diffids 0]
+ if {$diffid == $nullid} {
+ return
+ } elseif {$diffid == $nullid2} {
+ set diffidtext [mc "index"]
+ set diffid ""
+ set whattext $diffidtext
+ } else {
+ set diffidtext [shortids $diffid]
+ set whattext "[mc "revision"] $diffidtext"
+ }
+ set diffid $diffid:
+ if {$cmitmode eq "tree"} {
+ set diffid $diffid./
+ }
+ set difffile "\[$diffidtext\] [file tail $flist_menu_file]"
+ set difffile [tk_getSaveFile -initialfile $difffile -title [mc "Save file as"] -parent .]
+ if {$difffile eq {}} {
+ return
+ }
+ save_file_from_commit $diffid$flist_menu_file $difffile $whattext
+}
+
proc external_diff {} {
global nullid nullid2
global flist_menu_file
--
2.10.2
^ permalink raw reply related
* [PATCH 6/6] Rename 'remotes/' to 'r../' in heads
From: Pierre Dumuid @ 2016-12-15 11:28 UTC (permalink / raw)
To: paulus, git; +Cc: Pierre Dumuid
In-Reply-To: <20161215112847.14719-1-pmdumuid@gmail.com>
Signed-off-by: Pierre Dumuid <pmdumuid@gmail.com>
---
gitk | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/gitk b/gitk
index 0903d2d..6f50b06 100755
--- a/gitk
+++ b/gitk
@@ -6731,22 +6731,28 @@ proc drawtags {id x xt y1} {
set yb [expr {$yt + $linespc - 1}]
set xvals {}
set wvals {}
+ set newTags {}
+
set i -1
foreach tag $marks {
incr i
+ set newTag $tag
+ regsub {^remotes} $newTag "r.." newTag
+
if {$i >= $ntags && $i < $ntags + $nheads && $tag eq $mainhead} {
- set wid [font measure mainfontbold $tag]
+ set wid [font measure mainfontbold $newTag]
} else {
- set wid [font measure mainfont $tag]
+ set wid [font measure mainfont $newTag]
}
lappend xvals $xt
lappend wvals $wid
+ lappend newTags $newTag
set xt [expr {$xt + $wid + $extra}]
}
set t [$canv create line $x $y1 [lindex $xvals end] $y1 \
-width $lthickness -fill $reflinecolor -tags tag.$id]
$canv lower $t
- foreach tag $marks x $xvals wid $wvals {
+ foreach tag $marks x $xvals wid $wvals newTag $newTags {
set tag_quoted [string map {% %%} $tag]
set xl [expr {$x + $delta}]
set xr [expr {$x + $delta + $wid + $lthickness}]
@@ -6778,7 +6784,10 @@ proc drawtags {id x xt y1} {
$canv create polygon $x $yt $xr $yt $xr $yb $x $yb \
-width 1 -outline black -fill $col -tags tag.$id
if {[regexp {^(remotes/.*/|remotes/)} $tag match remoteprefix]} {
- set rwid [font measure mainfont $remoteprefix]
+ set newRemotePrefix $remoteprefix
+ regsub {^remotes} $newRemotePrefix "r.." newRemotePrefix
+
+ set rwid [font measure mainfont $newRemotePrefix]
set xi [expr {$x + 1}]
set yti [expr {$yt + 1}]
set xri [expr {$x + $rwid}]
@@ -6786,7 +6795,7 @@ proc drawtags {id x xt y1} {
-width 0 -fill $remotebgcolor -tags tag.$id
}
}
- set t [$canv create text $xl $y1 -anchor w -text $tag -fill $headfgcolor \
+ set t [$canv create text $xl $y1 -anchor w -text $newTag -fill $headfgcolor \
-font $font -tags [list tag.$id text]]
if {$ntags >= 0} {
$canv bind $t <1> $tagclick
--
2.10.2
^ permalink raw reply related
* [PATCH 4/6] Add DirDiffTool as additional option
From: Pierre Dumuid @ 2016-12-15 11:28 UTC (permalink / raw)
To: paulus, git; +Cc: Pierre Dumuid
In-Reply-To: <20161215112847.14719-1-pmdumuid@gmail.com>
Signed-off-by: Pierre Dumuid <pmdumuid@gmail.com>
---
gitk | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/gitk b/gitk
index a894f1d..5f27716 100755
--- a/gitk
+++ b/gitk
@@ -2661,6 +2661,9 @@ proc makewindow {} {
{mc "Diff this -> marked commit" command {diffvsmark 0}}
{mc "Diff marked commit -> this" command {diffvsmark 1}}
{mc "Revert this commit" command revert}
+
+ {mc "DirDiffTool this -> selected" command {externalDiffToolVsSel 0}}
+ {mc "DirDiffTool selected -> this" command {externalDiffToolVsSel 1}}
}
$rowctxmenu configure -tearoff 0
@@ -9254,6 +9257,20 @@ proc diffvssel {dirn} {
doseldiff $oldid $newid
}
+proc externalDiffToolVsSel {diffDirection} {
+ global rowmenuid selectedline
+
+ if {$selectedline eq {}} return
+ if {$diffDirection} {
+ set oldid [commitonrow $selectedline]
+ set newid $rowmenuid
+ } else {
+ set oldid $rowmenuid
+ set newid [commitonrow $selectedline]
+ }
+ [exec git difftool -d $oldid $newid]
+}
+
proc diffvsmark {dirn} {
global rowmenuid markedid
--
2.10.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox