* [PATCHv4 2/5] submodule helper: support super prefix
From: Stefan Beller @ 2016-12-02 23:42 UTC (permalink / raw)
To: pclouds, bmwill, gitster; +Cc: git, Stefan Beller
In-Reply-To: <20161202234220.24664-1-sbeller@google.com>
Just like main commands in Git, the submodule helper needs
access to the superproject prefix. Enable this in the git.c
but have its own fuse in the helper code by having a flag to
turn on the super prefix.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/submodule--helper.c | 31 ++++++++++++++++++++-----------
git.c | 2 +-
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 4beeda5f9f..806e29ce4e 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1076,21 +1076,24 @@ static int resolve_remote_submodule_branch(int argc, const char **argv,
return 0;
}
+#define SUPPORT_SUPER_PREFIX (1<<0)
+
struct cmd_struct {
const char *cmd;
int (*fn)(int, const char **, const char *);
+ int option;
};
static struct cmd_struct commands[] = {
- {"list", module_list},
- {"name", module_name},
- {"clone", module_clone},
- {"update-clone", update_clone},
- {"relative-path", resolve_relative_path},
- {"resolve-relative-url", resolve_relative_url},
- {"resolve-relative-url-test", resolve_relative_url_test},
- {"init", module_init},
- {"remote-branch", resolve_remote_submodule_branch}
+ {"list", module_list, 0},
+ {"name", module_name, 0},
+ {"clone", module_clone, 0},
+ {"update-clone", update_clone, 0},
+ {"relative-path", resolve_relative_path, 0},
+ {"resolve-relative-url", resolve_relative_url, 0},
+ {"resolve-relative-url-test", resolve_relative_url_test, 0},
+ {"init", module_init, 0},
+ {"remote-branch", resolve_remote_submodule_branch, 0}
};
int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
@@ -1100,9 +1103,15 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
die(_("submodule--helper subcommand must be "
"called with a subcommand"));
- for (i = 0; i < ARRAY_SIZE(commands); i++)
- if (!strcmp(argv[1], commands[i].cmd))
+ for (i = 0; i < ARRAY_SIZE(commands); i++) {
+ if (!strcmp(argv[1], commands[i].cmd)) {
+ if (get_super_prefix() &&
+ !(commands[i].option & SUPPORT_SUPER_PREFIX))
+ die("%s doesn't support --super-prefix",
+ commands[i].cmd);
return commands[i].fn(argc - 1, argv + 1, prefix);
+ }
+ }
die(_("'%s' is not a valid submodule--helper "
"subcommand"), argv[1]);
diff --git a/git.c b/git.c
index efa1059fe0..98dcf6c518 100644
--- a/git.c
+++ b/git.c
@@ -493,7 +493,7 @@ static struct cmd_struct commands[] = {
{ "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
{ "stripspace", cmd_stripspace },
- { "submodule--helper", cmd_submodule__helper, RUN_SETUP },
+ { "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX},
{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
{ "tag", cmd_tag, RUN_SETUP },
{ "unpack-file", cmd_unpack_file, RUN_SETUP },
--
2.11.0.rc2.28.g2673dad
^ permalink raw reply related
* [PATCHv4 3/5] test-lib-functions.sh: teach test_commit -C <dir>
From: Stefan Beller @ 2016-12-02 23:42 UTC (permalink / raw)
To: pclouds, bmwill, gitster; +Cc: git, Stefan Beller
In-Reply-To: <20161202234220.24664-1-sbeller@google.com>
Specifically when setting up submodule tests, it comes in handy if
we can create commits in repositories that are not at the root of
the tested trash dir. Add "-C <dir>" similar to gits -C parameter
that will perform the operation in the given directory.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/test-lib-functions.sh | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index fdaeb3a96b..579e812506 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -157,16 +157,21 @@ debug () {
GIT_TEST_GDB=1 "$@"
}
-# Call test_commit with the arguments "<message> [<file> [<contents> [<tag>]]]"
+# Call test_commit with the arguments
+# [-C <directory>] <message> [<file> [<contents> [<tag>]]]"
#
# This will commit a file with the given contents and the given commit
# message, and tag the resulting commit with the given tag name.
#
# <file>, <contents>, and <tag> all default to <message>.
+#
+# If the first argument is "-C", the second argument is used as a path for
+# the git invocations.
test_commit () {
notick= &&
signoff= &&
+ indir= &&
while test $# != 0
do
case "$1" in
@@ -176,21 +181,26 @@ test_commit () {
--signoff)
signoff="$1"
;;
+ -C)
+ indir="$2"
+ shift
+ ;;
*)
break
;;
esac
shift
done &&
+ indir=${indir:+"$indir"/} &&
file=${2:-"$1.t"} &&
- echo "${3-$1}" > "$file" &&
- git add "$file" &&
+ echo "${3-$1}" > "$indir$file" &&
+ git ${indir:+ -C "$indir"} add "$file" &&
if test -z "$notick"
then
test_tick
fi &&
- git commit $signoff -m "$1" &&
- git tag "${4:-$1}"
+ git ${indir:+ -C "$indir"} commit $signoff -m "$1" &&
+ git ${indir:+ -C "$indir"} tag "${4:-$1}"
}
# Call test_merge with the arguments "<message> <commit>", where <commit>
--
2.11.0.rc2.28.g2673dad
^ permalink raw reply related
* [PATCHv4 5/5] submodule: add embed-git-dir function
From: Stefan Beller @ 2016-12-02 23:42 UTC (permalink / raw)
To: pclouds, bmwill, gitster; +Cc: git, Stefan Beller
In-Reply-To: <20161202234220.24664-1-sbeller@google.com>
When a submodule has its git dir inside the working dir, the submodule
support for checkout that we plan to add in a later patch will fail.
Add functionality to migrate the git directory to be embedded
into the superprojects git directory.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/git-submodule.txt | 14 ++++++
builtin/submodule--helper.c | 62 ++++++++++++++++++++++-
dir.c | 81 ++++++++++++++++++++++++++++++
dir.h | 4 ++
git-submodule.sh | 7 ++-
t/t7412-submodule-embedgitdirs.sh | 101 ++++++++++++++++++++++++++++++++++++++
6 files changed, 267 insertions(+), 2 deletions(-)
create mode 100755 t/t7412-submodule-embedgitdirs.sh
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index d841573475..34791cfc65 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -22,6 +22,7 @@ SYNOPSIS
[commit] [--] [<path>...]
'git submodule' [--quiet] foreach [--recursive] <command>
'git submodule' [--quiet] sync [--recursive] [--] [<path>...]
+'git submodule' [--quiet] embedgitdirs [--] [<path>...]
DESCRIPTION
@@ -245,6 +246,19 @@ sync::
If `--recursive` is specified, this command will recurse into the
registered submodules, and sync any nested submodules within.
+embedgitdirs::
+ Move the git directory of submodules into its superprojects
+ `$GIT_DIR/modules` path and then connect the git directory and
+ its working directory by setting the `core.worktree` and adding
+ a .git file pointing to the git directory interned into the
+ superproject.
++
+A repository that was cloned independently and later added as a submodule or
+old setups have the submodules git directory inside the submodule instead of
+embedded into the superprojects git directory.
++
+This command is recursive by default.
+
OPTIONS
-------
-q::
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 806e29ce4e..10df69c86a 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1076,6 +1076,65 @@ static int resolve_remote_submodule_branch(int argc, const char **argv,
return 0;
}
+static int embed_git_dir(int argc, const char **argv, const char *prefix)
+{
+ int i;
+ struct pathspec pathspec;
+ struct module_list list = MODULE_LIST_INIT;
+ unsigned flags = RELOCATE_GITDIR_RECURSE_SUBMODULES;
+
+ struct option embed_gitdir_options[] = {
+ OPT_STRING(0, "prefix", &prefix,
+ N_("path"),
+ N_("path into the working tree")),
+ OPT_BIT(0, "--recursive", &flags, N_("recurse into submodules"),
+ RELOCATE_GITDIR_RECURSE_SUBMODULES),
+ OPT_END()
+ };
+
+ const char *const git_submodule_helper_usage[] = {
+ N_("git submodule--helper embed-git-dir [<path>...]"),
+ NULL
+ };
+
+ argc = parse_options(argc, argv, prefix, embed_gitdir_options,
+ git_submodule_helper_usage, 0);
+
+ gitmodules_config();
+ git_config(submodule_config, NULL);
+
+ if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
+ return 1;
+
+ for (i = 0; i < list.nr; i++) {
+ const char *path = list.entries[i]->name, *sub_git_dir, *v;
+ char *real_sub_git_dir = NULL, *real_common_git_dir = NULL;
+ struct strbuf gitdir = STRBUF_INIT;
+
+ strbuf_addf(&gitdir, "%s/.git", path);
+ sub_git_dir = resolve_gitdir(gitdir.buf);
+
+ /* not populated? */
+ if (!sub_git_dir)
+ goto free_and_continue;
+
+ /* Is it already embedded? */
+ real_sub_git_dir = xstrdup(real_path(sub_git_dir));
+ real_common_git_dir = xstrdup(real_path(get_git_common_dir()));
+ if (skip_prefix(real_sub_git_dir, real_common_git_dir, &v), NULL)
+ goto free_and_continue;
+
+ relocate_gitdir(prefix, path, flags);
+
+free_and_continue:
+ strbuf_release(&gitdir);
+ free(real_sub_git_dir);
+ free(real_common_git_dir);
+ }
+
+ return 0;
+}
+
#define SUPPORT_SUPER_PREFIX (1<<0)
struct cmd_struct {
@@ -1093,7 +1152,8 @@ static struct cmd_struct commands[] = {
{"resolve-relative-url", resolve_relative_url, 0},
{"resolve-relative-url-test", resolve_relative_url_test, 0},
{"init", module_init, 0},
- {"remote-branch", resolve_remote_submodule_branch, 0}
+ {"remote-branch", resolve_remote_submodule_branch, 0},
+ {"embed-git-dirs", embed_git_dir, SUPPORT_SUPER_PREFIX}
};
int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
diff --git a/dir.c b/dir.c
index bfa8c8a9a5..d2f60b5abf 100644
--- a/dir.c
+++ b/dir.c
@@ -15,6 +15,9 @@
#include "utf8.h"
#include "varint.h"
#include "ewah/ewok.h"
+#include "submodule-config.h"
+#include "run-command.h"
+#include "worktree.h"
struct path_simplify {
int len;
@@ -2748,3 +2751,81 @@ void untracked_cache_add_to_index(struct index_state *istate,
{
untracked_cache_invalidate_path(istate, path);
}
+
+/*
+ * Migrate the given submodule (and all its submodules recursively) from
+ * having its git directory within the working tree to the git dir nested
+ * in its superprojects git dir under modules/.
+ */
+void relocate_gitdir(const char *prefix, const char *path, unsigned flags)
+{
+ char *old_git_dir;
+ const char *new_git_dir;
+ const struct submodule *sub;
+ struct worktree **worktrees;
+ int i;
+
+ worktrees = get_submodule_worktrees(path, 0);
+ if (worktrees) {
+ for (i = 0; worktrees[i]; i++)
+ ;
+ free_worktrees(worktrees);
+ if (i > 1)
+ die(_("relocate_gitdir for submodule with more than one worktree not supported"));
+ }
+
+ old_git_dir = xstrfmt("%s/.git", path);
+ if (read_gitfile(old_git_dir))
+ /* If it is an actual gitfile, it doesn't need migration. */
+ goto out;
+
+ sub = submodule_from_path(null_sha1, path);
+ if (!sub)
+ die(_("Could not lookup name for submodule '%s'"),
+ path);
+
+ new_git_dir = git_path("modules/%s", sub->name);
+ if (safe_create_leading_directories_const(new_git_dir) < 0)
+ die(_("could not create directory '%s'"), new_git_dir);
+
+ if (!prefix)
+ prefix = get_super_prefix();
+ printf("Migrating git directory of %s%s from\n'%s' to\n'%s'\n",
+ prefix ? prefix : "", path,
+ real_path(old_git_dir), new_git_dir);
+
+ if (rename(old_git_dir, new_git_dir) < 0)
+ die_errno(_("Could not migrate git directory from '%s' to '%s'"),
+ old_git_dir, new_git_dir);
+
+ connect_work_tree_and_git_dir(path, new_git_dir);
+
+out:
+ if (flags & RELOCATE_GITDIR_RECURSE_SUBMODULES) {
+ struct child_process cp = CHILD_PROCESS_INIT;
+ struct strbuf sb = STRBUF_INIT;
+
+ if (flags & ~RELOCATE_GITDIR_RECURSE_SUBMODULES)
+ die("BUG: we don't know how to pass the flags down?");
+
+ if (get_super_prefix())
+ strbuf_addstr(&sb, get_super_prefix());
+ strbuf_addstr(&sb, path);
+ strbuf_addch(&sb, '/');
+
+ cp.dir = path;
+ cp.git_cmd = 1;
+ cp.no_stdin = 1;
+ argv_array_pushl(&cp.args, "--super-prefix", sb.buf,
+ "submodule--helper",
+ "embed-git-dirs", NULL);
+ prepare_submodule_repo_env(&cp.env_array);
+ if (run_command(&cp))
+ die(_("Could not migrate git directory in submodule '%s'"),
+ path);
+
+ strbuf_release(&sb);
+ }
+
+ free(old_git_dir);
+}
diff --git a/dir.h b/dir.h
index 97c83bb383..0b5e99b21d 100644
--- a/dir.h
+++ b/dir.h
@@ -335,4 +335,8 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long
void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);
void add_untracked_cache(struct index_state *istate);
void remove_untracked_cache(struct index_state *istate);
+
+#define RELOCATE_GITDIR_RECURSE_SUBMODULES (1<<0)
+extern void relocate_gitdir(const char *prefix, const char *path, unsigned flags);
+
#endif
diff --git a/git-submodule.sh b/git-submodule.sh
index a024a135d6..b7e124f340 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -1131,6 +1131,11 @@ cmd_sync()
done
}
+cmd_embedgitdirs()
+{
+ git submodule--helper embed-git-dirs --prefix "$wt_prefix" "$@"
+}
+
# This loop parses the command line arguments to find the
# subcommand name to dispatch. Parsing of the subcommand specific
# options are primarily done by the subcommand implementations.
@@ -1140,7 +1145,7 @@ cmd_sync()
while test $# != 0 && test -z "$command"
do
case "$1" in
- add | foreach | init | deinit | update | status | summary | sync)
+ add | foreach | init | deinit | update | status | summary | sync | embedgitdirs)
command=$1
;;
-q|--quiet)
diff --git a/t/t7412-submodule-embedgitdirs.sh b/t/t7412-submodule-embedgitdirs.sh
new file mode 100755
index 0000000000..a02e7c447a
--- /dev/null
+++ b/t/t7412-submodule-embedgitdirs.sh
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+test_description='Test submodule embedgitdirs
+
+This test verifies that `git submodue embedgitdirs` moves a submodules git
+directory into the superproject.
+'
+
+. ./test-lib.sh
+
+test_expect_success 'setup a real submodule' '
+ git init sub1 &&
+ test_commit -C sub1 first &&
+ git submodule add ./sub1 &&
+ test_tick &&
+ git commit -m superproject
+'
+
+test_expect_success 'embed the git dir' '
+ >expect.1 &&
+ >expect.2 &&
+ >actual.1 &&
+ >actual.2 &&
+ git status >expect.1 &&
+ git -C sub1 rev-parse HEAD >expect.2 &&
+ git submodule embedgitdirs &&
+ git fsck &&
+ test -f sub1/.git &&
+ test -d .git/modules/sub1 &&
+ git status >actual.1 &&
+ git -C sub1 rev-parse HEAD >actual.2 &&
+ test_cmp expect.1 actual.1 &&
+ test_cmp expect.2 actual.2
+'
+
+test_expect_success 'embedding does not fail for deinitalized submodules' '
+ test_when_finished "git submodule update --init" &&
+ git submodule deinit --all &&
+ git submodule embedgitdirs &&
+ test -d .git/modules/sub1 &&
+ ! test -f sub1/.git &&
+ test -d sub1
+'
+
+test_expect_success 'setup nested submodule' '
+ git init sub1/nested &&
+ test_commit -C sub1/nested first_nested &&
+ git -C sub1 submodule add ./nested &&
+ test_tick &&
+ git -C sub1 commit -m "add nested" &&
+ git add sub1 &&
+ git commit -m "sub1 to include nested submodule"
+'
+
+test_expect_success 'embed the git dir in a nested submodule' '
+ git status >expect.1 &&
+ git -C sub1/nested rev-parse HEAD >expect.2 &&
+ git submodule embedgitdirs &&
+ test -f sub1/nested/.git &&
+ test -d .git/modules/sub1/modules/nested &&
+ git status >actual.1 &&
+ git -C sub1/nested rev-parse HEAD >actual.2 &&
+ test_cmp expect.1 actual.1 &&
+ test_cmp expect.2 actual.2
+'
+
+test_expect_success 'setup a gitlink with missing .gitmodules entry' '
+ git init sub2 &&
+ test_commit -C sub2 first &&
+ git add sub2 &&
+ git commit -m superproject
+'
+
+test_expect_success 'embedding the git dir fails for incomplete submodules' '
+ git status >expect.1 &&
+ git -C sub2 rev-parse HEAD >expect.2 &&
+ test_must_fail git submodule embedgitdirs &&
+ git -C sub2 fsck &&
+ test -d sub2/.git &&
+ git status >actual &&
+ git -C sub2 rev-parse HEAD >actual.2 &&
+ test_cmp expect.1 actual.1 &&
+ test_cmp expect.2 actual.2
+'
+
+test_expect_success 'setup a submodule with multiple worktrees' '
+ # first create another unembedded git dir in a new submodule
+ git init sub3 &&
+ test_commit -C sub3 first &&
+ git submodule add ./sub3 &&
+ test_tick &&
+ git commit -m "add another submodule" &&
+ git -C sub3 worktree add ../sub3_second_work_tree
+'
+
+test_expect_success 'embed a submodule with multiple worktrees' '
+ test_must_fail git submodule embedgitdirs sub3 2>error &&
+ test_i18ngrep "not supported" error
+'
+
+test_done
--
2.11.0.rc2.28.g2673dad
^ permalink raw reply related
* [PATCHv4 4/5] worktree: get worktrees from submodules
From: Stefan Beller @ 2016-12-02 23:42 UTC (permalink / raw)
To: pclouds, bmwill, gitster; +Cc: git, Stefan Beller
In-Reply-To: <20161202234220.24664-1-sbeller@google.com>
In a later patch we want to move around the the git directory of
a submodule. Both submodules as well as worktrees are involved in
placing git directories at unusual places, so their functionality
may collide. To react appropriately to situations where worktrees
in submodules are in use, offer a new function to query the
worktrees for submodules.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
worktree.c | 47 +++++++++++++++++++++++++++++++++++++----------
worktree.h | 6 ++++++
2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/worktree.c b/worktree.c
index eb6121263b..fa2b6dfa9a 100644
--- a/worktree.c
+++ b/worktree.c
@@ -72,7 +72,7 @@ static void add_head_info(struct strbuf *head_ref, struct worktree *worktree)
/**
* get the main worktree
*/
-static struct worktree *get_main_worktree(void)
+static struct worktree *get_main_worktree(const char *git_common_dir)
{
struct worktree *worktree = NULL;
struct strbuf path = STRBUF_INIT;
@@ -81,12 +81,12 @@ static struct worktree *get_main_worktree(void)
int is_bare = 0;
int is_detached = 0;
- strbuf_add_absolute_path(&worktree_path, get_git_common_dir());
+ strbuf_add_absolute_path(&worktree_path, git_common_dir);
is_bare = !strbuf_strip_suffix(&worktree_path, "/.git");
if (is_bare)
strbuf_strip_suffix(&worktree_path, "/.");
- strbuf_addf(&path, "%s/HEAD", get_git_common_dir());
+ strbuf_addf(&path, "%s/HEAD", git_common_dir);
worktree = xcalloc(1, sizeof(*worktree));
worktree->path = strbuf_detach(&worktree_path, NULL);
@@ -101,7 +101,8 @@ static struct worktree *get_main_worktree(void)
return worktree;
}
-static struct worktree *get_linked_worktree(const char *id)
+static struct worktree *get_linked_worktree(const char *git_common_dir,
+ const char *id)
{
struct worktree *worktree = NULL;
struct strbuf path = STRBUF_INIT;
@@ -112,7 +113,7 @@ static struct worktree *get_linked_worktree(const char *id)
if (!id)
die("Missing linked worktree name");
- strbuf_git_common_path(&path, "worktrees/%s/gitdir", id);
+ strbuf_addf(&path, "%s/worktrees/%s/gitdir", git_common_dir, id);
if (strbuf_read_file(&worktree_path, path.buf, 0) <= 0)
/* invalid gitdir file */
goto done;
@@ -125,7 +126,7 @@ static struct worktree *get_linked_worktree(const char *id)
}
strbuf_reset(&path);
- strbuf_addf(&path, "%s/worktrees/%s/HEAD", get_git_common_dir(), id);
+ strbuf_addf(&path, "%s/worktrees/%s/HEAD", git_common_dir, id);
if (parse_ref(path.buf, &head_ref, &is_detached) < 0)
goto done;
@@ -167,7 +168,8 @@ static int compare_worktree(const void *a_, const void *b_)
return fspathcmp((*a)->path, (*b)->path);
}
-struct worktree **get_worktrees(unsigned flags)
+static struct worktree **get_worktrees_internal(const char *git_common_dir,
+ unsigned flags)
{
struct worktree **list = NULL;
struct strbuf path = STRBUF_INIT;
@@ -177,9 +179,9 @@ struct worktree **get_worktrees(unsigned flags)
list = xmalloc(alloc * sizeof(struct worktree *));
- list[counter++] = get_main_worktree();
+ list[counter++] = get_main_worktree(git_common_dir);
- strbuf_addf(&path, "%s/worktrees", get_git_common_dir());
+ strbuf_addf(&path, "%s/worktrees", git_common_dir);
dir = opendir(path.buf);
strbuf_release(&path);
if (dir) {
@@ -188,7 +190,7 @@ struct worktree **get_worktrees(unsigned flags)
if (is_dot_or_dotdot(d->d_name))
continue;
- if ((linked = get_linked_worktree(d->d_name))) {
+ if ((linked = get_linked_worktree(git_common_dir, d->d_name))) {
ALLOC_GROW(list, counter + 1, alloc);
list[counter++] = linked;
}
@@ -209,6 +211,31 @@ struct worktree **get_worktrees(unsigned flags)
return list;
}
+struct worktree **get_worktrees(unsigned flags)
+{
+ return get_worktrees_internal(get_git_common_dir(), flags);
+}
+
+struct worktree **get_submodule_worktrees(const char *path, unsigned flags)
+{
+ char *submodule_gitdir;
+ const char *submodule_common_dir;
+ struct strbuf sb = STRBUF_INIT;
+ struct worktree **ret;
+
+ submodule_gitdir = git_pathdup_submodule(path, "%s", "");
+ if (!submodule_gitdir)
+ return NULL;
+
+ /* the env would be set for the superproject */
+ get_common_dir_noenv(&sb, submodule_gitdir);
+ submodule_common_dir = strbuf_detach(&sb, NULL);
+ ret = get_worktrees_internal(submodule_common_dir, flags);
+
+ free(submodule_gitdir);
+ return ret;
+}
+
const char *get_worktree_git_dir(const struct worktree *wt)
{
if (!wt)
diff --git a/worktree.h b/worktree.h
index d59ce1fee8..157fbc4a66 100644
--- a/worktree.h
+++ b/worktree.h
@@ -27,6 +27,12 @@ struct worktree {
*/
extern struct worktree **get_worktrees(unsigned flags);
+/*
+ * Get the worktrees of a submodule named by `path`.
+ */
+extern struct worktree **get_submodule_worktrees(const char *path,
+ unsigned flags);
+
/*
* Return git dir of the worktree. Note that the path may be relative.
* If wt is NULL, git dir of current worktree is returned.
--
2.11.0.rc2.28.g2673dad
^ permalink raw reply related
* [PATCHv4 1/5] submodule: use absolute path for computing relative path connecting
From: Stefan Beller @ 2016-12-02 23:42 UTC (permalink / raw)
To: pclouds, bmwill, gitster; +Cc: git, Stefan Beller
In-Reply-To: <20161202234220.24664-1-sbeller@google.com>
The current caller of connect_work_tree_and_git_dir passes
an absolute path for the `git_dir` parameter. In the future patch
we will also pass in relative path for `git_dir`. Extend the functionality
of connect_work_tree_and_git_dir to take relative paths for parameters.
We could work around this in the future patch by computing the absolute
path for the git_dir in the calling site, however accepting relative
paths for either parameter makes the API for this function much harder
to misuse.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
submodule.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/submodule.c b/submodule.c
index 6f7d883de9..66c5ce5a24 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1227,23 +1227,25 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
{
struct strbuf file_name = STRBUF_INIT;
struct strbuf rel_path = STRBUF_INIT;
- const char *real_work_tree = xstrdup(real_path(work_tree));
+ char *real_git_dir = xstrdup(real_path(git_dir));
+ char *real_work_tree = xstrdup(real_path(work_tree));
/* Update gitfile */
strbuf_addf(&file_name, "%s/.git", work_tree);
write_file(file_name.buf, "gitdir: %s",
- relative_path(git_dir, real_work_tree, &rel_path));
+ relative_path(real_git_dir, real_work_tree, &rel_path));
/* Update core.worktree setting */
strbuf_reset(&file_name);
- strbuf_addf(&file_name, "%s/config", git_dir);
+ strbuf_addf(&file_name, "%s/config", real_git_dir);
git_config_set_in_file(file_name.buf, "core.worktree",
- relative_path(real_work_tree, git_dir,
+ relative_path(real_work_tree, real_git_dir,
&rel_path));
strbuf_release(&file_name);
strbuf_release(&rel_path);
- free((void *)real_work_tree);
+ free(real_work_tree);
+ free(real_git_dir);
}
int parallel_submodules(void)
--
2.11.0.rc2.28.g2673dad
^ permalink raw reply related
* [PATCHv4 0/5] submodule embedgitdirs
From: Stefan Beller @ 2016-12-02 23:42 UTC (permalink / raw)
To: pclouds, bmwill, gitster; +Cc: git, Stefan Beller
v4:
* rebuilt on top of nd/worktree-list-fixup
* fix and test behavior for un-init submodules (don't crash, rather do nothing)
* incorporated a "static" as pointed out by Ramsay
* use internal functions instead of duplicating code in worktree.c
(use get_common_dir_noenv for the submodule to actually get the common dir)
* fixed a memory leak in relocate_gitdir
Stefan Beller (5):
submodule: use absolute path for computing relative path connecting
submodule helper: support super prefix
test-lib-functions.sh: teach test_commit -C <dir>
worktree: get worktrees from submodules
submodule: add embed-git-dir function
Documentation/git-submodule.txt | 14 ++++++
builtin/submodule--helper.c | 91 +++++++++++++++++++++++++++++-----
dir.c | 81 ++++++++++++++++++++++++++++++
dir.h | 4 ++
git-submodule.sh | 7 ++-
git.c | 2 +-
submodule.c | 12 +++--
t/t7412-submodule-embedgitdirs.sh | 101 ++++++++++++++++++++++++++++++++++++++
t/test-lib-functions.sh | 20 ++++++--
worktree.c | 47 ++++++++++++++----
worktree.h | 6 +++
11 files changed, 352 insertions(+), 33 deletions(-)
create mode 100755 t/t7412-submodule-embedgitdirs.sh
v3:
* have a slightly more generic function "relocate_gitdir".
The recursion is strictly related to submodules, though.
* bail out if a submodule is using worktrees.
This also lays the groundwork for later doing the proper thing,
as worktree.h offers a function `get_submodule_worktrees(path)`
* nit by duy: use git_path instead of git_common_dir
* diff to v2 (as queued by Junio) below.
v2:
* fixed commit message for patch:
"submodule: use absolute path for computing relative path connecting"
* a new patch "submodule helper: support super prefix"
* redid the final patch with more tests and fixing bugs along the way
* "test-lib-functions.sh: teach test_commit -C <dir>" unchanged
v1:
The discussion of the submodule checkout series revealed to me that a command
is needed to move the git directory from the submodules working tree to be
embedded into the superprojects git directory.
So I wrote the code to intern the submodules git dir into the superproject,
but whilst writing the code I realized this could be valueable for our use
in testing too. So I exposed it via the submodule--helper. But as the
submodule helper ought to be just an internal API, we could also
offer it via the proper submodule command.
The command as it is has little value to the end user for now, but
breaking it out of the submodule checkout series hopefully makes review easier.
Thanks,
Stefan
--
2.11.0.rc2.28.g2673dad
^ permalink raw reply
* difftool -d not populating left correctly when not in git root
From: Frank Becker @ 2016-12-02 23:04 UTC (permalink / raw)
To: git
Hi,
looks like this broke between 2.9.2 and 2.9.3
cat ~/.gitconfig
[difftool "diff"]
cmd = ls -l ${LOCAL}/* ${REMOTE}/*
#cmd = diff -r ${LOCAL} ${REMOTE} | less
~/stuff/gittest> ls -l *
d1:
total 8
-rw-r--r-- 1 frank staff 16 2 Dec 14:30 test.txt
d2:
total 8
-rw-r--r-- 1 frank staff 18 2 Dec 14:30 anothertest.tst
~/stuff/gittest> git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: d1/test.txt
modified: d2/anothertest.tst
~/stuff/gittest> ~/stuff/git_tmp/bin/git --version
git version 2.11.0
~/stuff/gittest> ~/stuff/git_tmp/bin/git difftool -d -t diff
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.0oGRF/left/d1:
total 8
-rw-r--r-- 1 frank staff 6 2 Dec 14:52 test.txt
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.0oGRF/left/d2:
total 8
-rw-r--r-- 1 frank staff 7 2 Dec 14:52 anothertest.tst
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.0oGRF/right/d1:
total 8
lrwxr-xr-x 1 frank staff 38 2 Dec 14:52 test.txt ->
/Users/frank/stuff/gittest/d1/test.txt
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.0oGRF/right/d2:
total 8
lrwxr-xr-x 1 frank staff 45 2 Dec 14:52 anothertest.tst ->
/Users/frank/stuff/gittest/d2/anothertest.tst
cd d2
~/stuff/gittest/d2> ~/stuff/git_tmp/bin/git difftool -d -t diff
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.eRXhB/left/d2:
total 8
-rw-r--r-- 1 frank staff 7 2 Dec 14:52 anothertest.tst
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.eRXhB/right/d1:
total 8
lrwxr-xr-x 1 frank staff 38 2 Dec 14:52 test.txt ->
/Users/frank/stuff/gittest/d1/test.txt
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.eRXhB/right/d2:
total 8
lrwxr-xr-x 1 frank staff 45 2 Dec 14:52 anothertest.tst ->
/Users/frank/stuff/gittest/d2/anothertest.tst
Note that left does not contain d1
~/stuff/gittest/d2> ~/stuff/git_tmp/bin/git --version
git version 2.9.2
~/stuff/gittest/d2> ~/stuff/git_tmp/bin/git difftool -d -t diff
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.YxtVw/left/d1:
total 8
-rw-r--r-- 1 frank staff 6 2 Dec 15:02 test.txt
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.YxtVw/left/d2:
total 8
-rw-r--r-- 1 frank staff 7 2 Dec 15:02 anothertest.tst
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.YxtVw/right/d1:
total 8
lrwxr-xr-x 1 frank staff 38 2 Dec 15:02 test.txt ->
/Users/frank/stuff/gittest/d1/test.txt
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.YxtVw/right/d2:
total 8
lrwxr-xr-x 1 frank staff 45 2 Dec 15:02 anothertest.tst ->
/Users/frank/stuff/gittest/d2/anothertest.tst
~/stuff/gittest/d2> ~/stuff/git_tmp/bin/git --version
git version 2.9.3
~/stuff/gittest/d2> ~/stuff/git_tmp/bin/git difftool -d -t diff
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.TpJ5u/left/d2:
total 8
-rw-r--r-- 1 frank staff 7 2 Dec 15:01 anothertest.tst
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.TpJ5u/right/d1:
total 8
lrwxr-xr-x 1 frank staff 38 2 Dec 15:01 test.txt ->
/Users/frank/stuff/gittest/d1/test.txt
/var/folders/0j/3pk3pdsx7rzb9_njdpyjwm000000gn/T/git-difftool.TpJ5u/right/d2:
total 8
lrwxr-xr-x 1 frank staff 45 2 Dec 15:01 anothertest.tst ->
/Users/frank/stuff/gittest/d2/anothertest.tst
Cheers,
Frank.
^ permalink raw reply
* [PATCHv1 2/2] git-p4: support updating an existing shelved changelist
From: Luke Diamand @ 2016-12-02 22:43 UTC (permalink / raw)
To: git; +Cc: Vinicius Kursancew, larsxschneider, Luke Diamand
In-Reply-To: <20161202224319.5385-1-luke@diamand.org>
Adds new option "--update-shelve CHANGELIST" which updates
an existing shelved changelist.
The original changelist must have been created by the current user.
This allows workflow something like:
hack hack hack
git commit
git p4 submit --shelve
$mail interested parties about shelved changelist
make corrections
git commit --amend
git p4 submit --update-shelve $CHANGELIST
$mail interested parties about shelved changelist
etc
Signed-off-by: Luke Diamand <luke@diamand.org>
---
Documentation/git-p4.txt | 4 ++++
git-p4.py | 33 +++++++++++++++++++++++++++++----
t/t9807-git-p4-submit.sh | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index 1bbf43d15..ce40b9a54 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -308,6 +308,10 @@ These options can be used to modify 'git p4 submit' behavior.
After creating each shelve, the relevant files are reverted/deleted.
If you have multiple commits pending multiple shelves will be created.
+--update-shelve CHANGELIST::
+ Update an existing shelved changelist with this commit. Implies
+ --shelve.
+
--conflict=(ask|skip|quit)::
Conflicts can occur when applying a commit to p4. When this
happens, the default behavior ("ask") is to prompt whether to
diff --git a/git-p4.py b/git-p4.py
index 5e2db1919..36242d384 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -262,6 +262,10 @@ def p4_revert(f):
def p4_reopen(type, f):
p4_system(["reopen", "-t", type, wildcard_encode(f)])
+def p4_reopen_in_change(changelist, files):
+ cmd = ["reopen", "-c", str(changelist)] + files
+ p4_system(cmd)
+
def p4_move(src, dest):
p4_system(["move", "-k", wildcard_encode(src), wildcard_encode(dest)])
@@ -1298,6 +1302,9 @@ class P4Submit(Command, P4UserMap):
optparse.make_option("--shelve", dest="shelve", action="store_true",
help="Shelve instead of submit. Shelved files are reverted, "
"restoring the workspace to the state before the shelve"),
+ optparse.make_option("--update-shelve", dest="update_shelve", action="store", type="int",
+ metavar="CHANGELIST",
+ help="update an existing shelved changelist, implies --shelve")
]
self.description = "Submit changes from git to the perforce depot."
self.usage += " [name of git branch to submit into perforce depot]"
@@ -1306,6 +1313,7 @@ class P4Submit(Command, P4UserMap):
self.preserveUser = gitConfigBool("git-p4.preserveUser")
self.dry_run = False
self.shelve = False
+ self.update_shelve = None
self.prepare_p4_only = False
self.conflict_behavior = None
self.isWindows = (platform.system() == "Windows")
@@ -1474,7 +1482,7 @@ class P4Submit(Command, P4UserMap):
return 1
return 0
- def prepareSubmitTemplate(self):
+ def prepareSubmitTemplate(self, changelist=None):
"""Run "p4 change -o" to grab a change specification template.
This does not use "p4 -G", as it is nice to keep the submission
template in original order, since a human might edit it.
@@ -1486,7 +1494,11 @@ class P4Submit(Command, P4UserMap):
template = ""
inFilesSection = False
- for line in p4_read_pipe_lines(['change', '-o']):
+ args = ['change', '-o']
+ if changelist:
+ args.append(str(changelist))
+
+ for line in p4_read_pipe_lines(args):
if line.endswith("\r\n"):
line = line[:-2] + "\n"
if inFilesSection:
@@ -1585,11 +1597,14 @@ class P4Submit(Command, P4UserMap):
editedFiles = set()
pureRenameCopy = set()
filesToChangeExecBit = {}
+ all_files = list()
for line in diff:
diff = parseDiffTreeEntry(line)
modifier = diff['status']
path = diff['src']
+ all_files.append(path)
+
if modifier == "M":
p4_edit(path)
if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
@@ -1715,6 +1730,10 @@ class P4Submit(Command, P4UserMap):
mode = filesToChangeExecBit[f]
setP4ExecBit(f, mode)
+ if self.update_shelve:
+ print("all_files = %s" % str(all_files))
+ p4_reopen_in_change(self.update_shelve, all_files)
+
#
# Build p4 change description, starting with the contents
# of the git commit message.
@@ -1723,7 +1742,7 @@ class P4Submit(Command, P4UserMap):
logMessage = logMessage.strip()
(logMessage, jobs) = self.separate_jobs_from_description(logMessage)
- template = self.prepareSubmitTemplate()
+ template = self.prepareSubmitTemplate(self.update_shelve)
submitTemplate = self.prepareLogMessage(template, logMessage, jobs)
if self.preserveUser:
@@ -1795,7 +1814,10 @@ class P4Submit(Command, P4UserMap):
if self.isWindows:
message = message.replace("\r\n", "\n")
submitTemplate = message[:message.index(separatorLine)]
- if self.shelve:
+
+ if self.update_shelve:
+ p4_write_pipe(['shelve', '-r', '-i'], submitTemplate)
+ elif self.shelve:
p4_write_pipe(['shelve', '-i'], submitTemplate)
else:
p4_write_pipe(['submit', '-i'], submitTemplate)
@@ -1921,6 +1943,9 @@ class P4Submit(Command, P4UserMap):
if len(self.origin) == 0:
self.origin = upstream
+ if self.update_shelve:
+ self.shelve = True
+
if self.preserveUser:
if not self.canChangeChangelists():
die("Cannot preserve user names without p4 super-user or admin permissions")
diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh
index 42a5fada5..e37239e65 100755
--- a/t/t9807-git-p4-submit.sh
+++ b/t/t9807-git-p4-submit.sh
@@ -444,6 +444,44 @@ test_expect_success 'submit --shelve' '
)
'
+# Update an existing shelved changelist
+
+test_expect_success 'submit --update-shelve' '
+ test_when_finished cleanup_git &&
+ git p4 clone --dest="$git" //depot &&
+ (
+ cd "$cli" &&
+ p4 revert ... &&
+ cd "$git" &&
+ git config git-p4.skipSubmitEdit true &&
+ test_commit "test-update-shelved-change" &&
+ git p4 submit --origin=HEAD^ --shelve &&
+
+ shelf_cl=$(p4 -G changes -s shelved -m 1 |\
+ marshal_dump change) &&
+ test -n $shelf_cl &&
+ echo "updating shelved change list $shelf_cl" &&
+
+ echo "updated-line" >>shelf.t &&
+ echo added-file.t >added-file.t &&
+ git add shelf.t added-file.t &&
+ git rm -f test-update-shelved-change.t &&
+ git commit --amend -C HEAD &&
+ git show --stat HEAD &&
+ git p4 submit -v --origin HEAD^ --update-shelve $shelf_cl &&
+ echo "done git p4 submit"
+ ) &&
+ (
+ cd "$cli" &&
+ change=$(p4 -G changes -s shelved -m 1 //depot/... | \
+ marshal_dump change) &&
+ p4 unshelve -c $change -s $change &&
+ grep -q updated-line shelf.t &&
+ p4 describe -S $change | grep added-file.t &&
+ test_path_is_missing test-update-shelved-change.t
+ )
+'
+
test_expect_success 'kill p4d' '
kill_p4d
'
--
2.11.0.274.g0ea315c
^ permalink raw reply related
* [PATCHv1 1/2] git-p4: support git-workspaces
From: Luke Diamand @ 2016-12-02 22:43 UTC (permalink / raw)
To: git; +Cc: Vinicius Kursancew, larsxschneider, Luke Diamand
In-Reply-To: <20161202224319.5385-1-luke@diamand.org>
Teach git-p4 about git-workspaces.
Signed-off-by: Luke Diamand <luke@diamand.org>
---
git-p4.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/git-p4.py b/git-p4.py
index 0c4f2afd2..5e2db1919 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -566,6 +566,12 @@ def isValidGitDir(path):
if (os.path.exists(path + "/HEAD")
and os.path.exists(path + "/refs") and os.path.exists(path + "/objects")):
return True;
+
+ # git workspace directory?
+ if (os.path.exists(path + "/HEAD")
+ and os.path.exists(path + "/gitdir")):
+ return True
+
return False
def parseRevision(ref):
--
2.11.0.274.g0ea315c
^ permalink raw reply related
* [PATCHv1 0/2] git-p4 patches
From: Luke Diamand @ 2016-12-02 22:43 UTC (permalink / raw)
To: git; +Cc: Vinicius Kursancew, larsxschneider, Luke Diamand
This is a couple of small patches for git-p4.
The first just teaches git-p4 about git workspaces, so that you can
do "git p4 submit" from within a workspace (P.S. workspaces
are completely *awesome*).
The second follows on from the work by Vinicius for shelving
changelists, by letting you update an existing shelved changelist.
This is a bit like using "git commit --amend" only far more painful....
Luke Diamand (2):
git-p4: support git-workspaces
git-p4: support updating an existing shelved changelist
Documentation/git-p4.txt | 4 ++++
git-p4.py | 39 +++++++++++++++++++++++++++++++++++----
t/t9807-git-p4-submit.sh | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+), 4 deletions(-)
--
2.11.0.274.g0ea315c
^ permalink raw reply
* Re: git 2.11.0 error when pushing to remote located on a windows share
From: Jeff King @ 2016-12-02 22:37 UTC (permalink / raw)
To: thomas.attwood; +Cc: git
In-Reply-To: <AABB04BF1441D24CB4E9FCF46394F17D666F34E1@exchmbx01>
On Fri, Dec 02, 2016 at 06:02:16PM +0000, thomas.attwood@stfc.ac.uk wrote:
> After updating git from 2.10.0 to 2.11.0 when trying to push any
> changes to a repo located in a windows share, the following error
> occurs:
>
> $ git push origin test
> Counting objects: 2, done.
> Delta compression using up to 8 threads.
> Compressing objects: 100% (2/2), done.
> Writing objects: 100% (2/2), 284 bytes | 0 bytes/s, done.
> Total 2 (delta 1), reused 1 (delta 0)
> remote: error: object directory /path/to/dir/objects does not exist; check .git/objects/info/alternates.
> remote: fatal: unresolved deltas left after unpacking
> error: unpack failed: unpack-objects abnormal exit
> To //path/to/dir
> ! [remote rejected] test -> test (unpacker error)
> error: failed to push some refs to '//path/to/dir'
Hmm. This is probably related to the quarantine-push change in v2.11;
the receiving end will write the objects into a temporary directory but
point to the original via GIT_ALTERNATE_OBJECT_DIRECTORIES. That pointer
isn't working for some reason, so the receiver can't resolve the deltas
it needs.
As you noted, the extra "/" is missing in the error message, and that
sounds like a plausible cause for what you're seeing. I'm not sure where
the slash is getting dropped, though. The value in the environment comes
from calling absolute_path(get_object_directory()), so I suspect the
real problem is not in the quarantine code, but it's just triggering a
latent bug elsewhere (either in absolute_path(), or in the code which
generates the objdir path).
> No error occurs if pushing to the same repo (a direct copy into a local directory) using 2.11.0.
>
> $ git push local_test test
> Counting objects: 2, done.
> Delta compression using up to 8 threads.
> Compressing objects: 100% (2/2), done.
> Writing objects: 100% (2/2), 284 bytes | 0 bytes/s, done.
> Total 2 (delta 1), reused 1 (delta 0)
> To C:/path/to/dir
> * [new branch] test -> test
The fact that it works using the non-UNC path reinforces my feeling that
something is normalizing the absolute path incorrectly.
> Using `git fsck --full` in both 2.11.0 and 2.10.0, it doesn't reveal any additional problems.
Yeah, I don't think there is anything wrong with your repo. It's just a
path-building issue internal to the receiving process.
-Peff
^ permalink raw reply
* Re: Where is Doc to configure Git + Apache + kerberos for Project level access in repo?
From: Jeff King @ 2016-12-02 22:21 UTC (permalink / raw)
To: ken edward; +Cc: git
In-Reply-To: <CAAqgmoNG4vOqLnOqmrUvwTNJpqGBckfN-y=Fc99TrvjPhz7h0w@mail.gmail.com>
On Fri, Dec 02, 2016 at 01:15:02PM -0500, ken edward wrote:
> Where is Doc to configure Git + Apache + kerberos for Project level
> access in repo?
I don't know about Kerberos, but all of the documentation in git for
configuring Apache is found in "git help http-backend".
-Peff
^ permalink raw reply
* [PATCH] commit: make --only --allow-empty work without paths
From: Andreas Krey @ 2016-12-02 22:15 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Jeff King
--only is implied when paths are present, and required
them unless --amend. But with --allow-empty it should
be allowed as well - it is the only way to create an
empty commit in the presence of staged changes.
Signed-off-by: Andreas Krey <a.krey@gmx.de>
---
I stumbled over this omission trying
to create an empty commit while changes
are staged. (We use such empty commits as
workaround when devs forgot to put issues
into the actual commits. And one had
staged changes at that point.)
Arguably, requiring paths with --only is
pointless anyway because it is implicit
in that case, but I'm happy when it works
like in this patch.
(The interdepence of the tests is a strange thing;
making --run=N somewhat pointless.)
(And I hope that the patch in commit.c is
actually sufficient for this, but have
not found indications to the contrary.)
Documentation/git-commit.txt | 3 ++-
builtin/commit.c | 2 +-
t/t7501-commit.sh | 9 +++++++++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index f2ab0ee2e..4f8f20a36 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -265,7 +265,8 @@ FROM UPSTREAM REBASE" section in linkgit:git-rebase[1].)
If this option is specified together with `--amend`, then
no paths need to be specified, which can be used to amend
the last commit without committing changes that have
- already been staged.
+ already been staged. If used together with `--allow-empty`
+ paths are also not required, and an empty commit will be created.
-u[<mode>]::
--untracked-files[=<mode>]::
diff --git a/builtin/commit.c b/builtin/commit.c
index 8976c3d29..89b66816f 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1206,7 +1206,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
if (also + only + all + interactive > 1)
die(_("Only one of --include/--only/--all/--interactive/--patch can be used."));
- if (argc == 0 && (also || (only && !amend)))
+ if (argc == 0 && (also || (only && !amend && !allow_empty)))
die(_("No paths with --include/--only does not make sense."));
if (argc == 0 && only && amend)
only_include_assumed = _("Clever... amending the last one with dirty index.");
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index d84897a67..0d8d89309 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -155,6 +155,15 @@ test_expect_success 'amend --only ignores staged contents' '
git diff --exit-code
'
+test_expect_success 'allow-empty --only ignores staged contents' '
+ echo changed-again >file &&
+ git add file &&
+ git commit --allow-empty --only -m "empty" &&
+ git cat-file blob HEAD:file >file.actual &&
+ test_cmp file.expect file.actual &&
+ git diff --exit-code
+'
+
test_expect_success 'set up editor' '
cat >editor <<-\EOF &&
#!/bin/sh
--
2.11.0.10.g1e1b186
--
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
^ permalink raw reply related
* Re: [PATCH] worktree: mark a file-local symbol with static
From: Stefan Beller @ 2016-12-02 21:58 UTC (permalink / raw)
To: Ramsay Jones; +Cc: Junio C Hamano, GIT Mailing-list
In-Reply-To: <0be15cd5-4ecb-3d87-93ee-d34d2be2d4c6@ramsayjones.plus.com>
On Fri, Dec 2, 2016 at 12:55 PM, Ramsay Jones
<ramsay@ramsayjones.plus.com> wrote:
>
> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
>
> Hi Stefan,
>
> If you need to re-roll your 'sb/submodule-intern-gitdir'
> branch,
I will need to reroll it.
> could you please squash something similar to this
> into the relevant patch (commit 2529715dc, "worktree: get
> worktrees from submodules", 01-12-2016).
>
> [This is based on pu; ie. on top of merge 86c7f863a, where
> Junio as added the 'flags' parameter.]
Oh, ok. I may just reroll the series on top of nd/worktree-list-fixup
Thanks for the annotation!
Stefan
^ permalink raw reply
* Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules
From: Brandon Williams @ 2016-12-02 21:46 UTC (permalink / raw)
To: Jacob Keller
Cc: Stefan Beller, Jeff King, Junio C Hamano, git@vger.kernel.org,
Jonathan Tan
In-Reply-To: <CA+P7+xpJ1=TiWq60wO4ftA-Y6SHAkdbLk=srbTQQsB=D1ZGkrw@mail.gmail.com>
On 12/02, Jacob Keller wrote:
> On Fri, Dec 2, 2016 at 11:28 AM, Stefan Beller <sbeller@google.com> wrote:
> > On Fri, Dec 2, 2016 at 11:20 AM, Jacob Keller <jacob.keller@gmail.com> wrote:
> >>>
> >>> So is there a reason why the library function realpath() can't be used?
> >>> From a cursory look at its man page it seems to do the symlink
> >>> resolution.
> >>>
> >>> --
> >>> Brandon Williams
> >>
> >> I believe it uses the same method and thus wouldn't actually resolve
> >> the issue. But I'm not really 100% sure on this.
> >>
> >> Thanks,
> >> Jake
> >
> > I just reviewed 2 libc implementations (glibc and an Android libc) and
> > both of them
> > do not use chdir internally, but use readlink and compose the path 'manually'
> > c.f. http://osxr.org:8080/glibc/source/stdlib/canonicalize.c?v=glibc-2.13
>
> Interesting. Would this be portable to Windows, though?
Perhaps. It looks like the only crazy thing it does is use readlink,
which our real_path function is already doing. I don't think we could
drop in their implementation though since there are other things that it
does that aren't portable to windows (like determining if a path is
absolute or not). Rather their implementation gives me some hope that
it is possible to resolve the real path without using chdir.
--
Brandon Williams
^ permalink raw reply
* Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules
From: Jeff King @ 2016-12-02 21:45 UTC (permalink / raw)
To: Stefan Beller
Cc: Jacob Keller, Brandon Williams, Junio C Hamano,
git@vger.kernel.org, Jonathan Tan
In-Reply-To: <CAGZ79kYPpc0=NAJaNPW+8faszOPAkq=b3m-EopY5A8oFwh+9=g@mail.gmail.com>
On Fri, Dec 02, 2016 at 11:28:49AM -0800, Stefan Beller wrote:
> I just reviewed 2 libc implementations (glibc and an Android libc) and
> both of them
> do not use chdir internally, but use readlink and compose the path 'manually'
> c.f. http://osxr.org:8080/glibc/source/stdlib/canonicalize.c?v=glibc-2.13
Interesting. It might be worth updating our implementation. The original
comes all the way from 54f4b8745 (Library code for user-relative paths,
take three., 2005-11-17). That references a suggestion which I think
comes from:
http://public-inbox.org/git/Pine.LNX.4.64.0510181728490.3369@g5.osdl.org/
where it's claimed to be simpler and more efficient (which sounds
plausible to me). But back then it was _just_ git-daemon doing a
canonicalization, and nobody cared about things like thread safety.
Looking at the glibc implementation, it's really not that bad. We
_could_ even rely on the system realpath() and just provide our own
fallback for systems without it, but I think ours might be a little more
featureful (at the very least, it handles arbitrary-sized paths via
strbufs).
-Peff
^ permalink raw reply
* [PATCH 2/2] unicode: update the tables to Unicode 9.0
From: Beat Bolli @ 2016-12-02 21:26 UTC (permalink / raw)
To: git; +Cc: Beat Bolli
In-Reply-To: <1480713995-16157-1-git-send-email-dev+git@drbeat.li>
A rerun of the previously fixed update-unicode.sh produces these new
tables.
Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
unicode_width.h | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 111 insertions(+), 11 deletions(-)
diff --git a/unicode_width.h b/unicode_width.h
index 47cdd23..73b5fd6 100644
--- a/unicode_width.h
+++ b/unicode_width.h
@@ -25,7 +25,7 @@ static const struct interval zero_width[] = {
{ 0x0825, 0x0827 },
{ 0x0829, 0x082D },
{ 0x0859, 0x085B },
-{ 0x08E4, 0x0902 },
+{ 0x08D4, 0x0902 },
{ 0x093A, 0x093A },
{ 0x093C, 0x093C },
{ 0x0941, 0x0948 },
@@ -120,6 +120,7 @@ static const struct interval zero_width[] = {
{ 0x17C9, 0x17D3 },
{ 0x17DD, 0x17DD },
{ 0x180B, 0x180E },
+{ 0x1885, 0x1886 },
{ 0x18A9, 0x18A9 },
{ 0x1920, 0x1922 },
{ 0x1927, 0x1928 },
@@ -158,7 +159,7 @@ static const struct interval zero_width[] = {
{ 0x1CF4, 0x1CF4 },
{ 0x1CF8, 0x1CF9 },
{ 0x1DC0, 0x1DF5 },
-{ 0x1DFC, 0x1DFF },
+{ 0x1DFB, 0x1DFF },
{ 0x200B, 0x200F },
{ 0x202A, 0x202E },
{ 0x2060, 0x2064 },
@@ -171,13 +172,13 @@ static const struct interval zero_width[] = {
{ 0x3099, 0x309A },
{ 0xA66F, 0xA672 },
{ 0xA674, 0xA67D },
-{ 0xA69F, 0xA69F },
+{ 0xA69E, 0xA69F },
{ 0xA6F0, 0xA6F1 },
{ 0xA802, 0xA802 },
{ 0xA806, 0xA806 },
{ 0xA80B, 0xA80B },
{ 0xA825, 0xA826 },
-{ 0xA8C4, 0xA8C4 },
+{ 0xA8C4, 0xA8C5 },
{ 0xA8E0, 0xA8F1 },
{ 0xA926, 0xA92D },
{ 0xA947, 0xA951 },
@@ -204,7 +205,7 @@ static const struct interval zero_width[] = {
{ 0xABED, 0xABED },
{ 0xFB1E, 0xFB1E },
{ 0xFE00, 0xFE0F },
-{ 0xFE20, 0xFE2D },
+{ 0xFE20, 0xFE2F },
{ 0xFEFF, 0xFEFF },
{ 0xFFF9, 0xFFFB },
{ 0x101FD, 0x101FD },
@@ -228,16 +229,21 @@ static const struct interval zero_width[] = {
{ 0x11173, 0x11173 },
{ 0x11180, 0x11181 },
{ 0x111B6, 0x111BE },
+{ 0x111CA, 0x111CC },
{ 0x1122F, 0x11231 },
{ 0x11234, 0x11234 },
{ 0x11236, 0x11237 },
+{ 0x1123E, 0x1123E },
{ 0x112DF, 0x112DF },
{ 0x112E3, 0x112EA },
-{ 0x11301, 0x11301 },
+{ 0x11300, 0x11301 },
{ 0x1133C, 0x1133C },
{ 0x11340, 0x11340 },
{ 0x11366, 0x1136C },
{ 0x11370, 0x11374 },
+{ 0x11438, 0x1143F },
+{ 0x11442, 0x11444 },
+{ 0x11446, 0x11446 },
{ 0x114B3, 0x114B8 },
{ 0x114BA, 0x114BA },
{ 0x114BF, 0x114C0 },
@@ -245,6 +251,7 @@ static const struct interval zero_width[] = {
{ 0x115B2, 0x115B5 },
{ 0x115BC, 0x115BD },
{ 0x115BF, 0x115C0 },
+{ 0x115DC, 0x115DD },
{ 0x11633, 0x1163A },
{ 0x1163D, 0x1163D },
{ 0x1163F, 0x11640 },
@@ -252,6 +259,16 @@ static const struct interval zero_width[] = {
{ 0x116AD, 0x116AD },
{ 0x116B0, 0x116B5 },
{ 0x116B7, 0x116B7 },
+{ 0x1171D, 0x1171F },
+{ 0x11722, 0x11725 },
+{ 0x11727, 0x1172B },
+{ 0x11C30, 0x11C36 },
+{ 0x11C38, 0x11C3D },
+{ 0x11C3F, 0x11C3F },
+{ 0x11C92, 0x11CA7 },
+{ 0x11CAA, 0x11CB0 },
+{ 0x11CB2, 0x11CB3 },
+{ 0x11CB5, 0x11CB6 },
{ 0x16AF0, 0x16AF4 },
{ 0x16B30, 0x16B36 },
{ 0x16F8F, 0x16F92 },
@@ -262,16 +279,28 @@ static const struct interval zero_width[] = {
{ 0x1D185, 0x1D18B },
{ 0x1D1AA, 0x1D1AD },
{ 0x1D242, 0x1D244 },
+{ 0x1DA00, 0x1DA36 },
+{ 0x1DA3B, 0x1DA6C },
+{ 0x1DA75, 0x1DA75 },
+{ 0x1DA84, 0x1DA84 },
+{ 0x1DA9B, 0x1DA9F },
+{ 0x1DAA1, 0x1DAAF },
+{ 0x1E000, 0x1E006 },
+{ 0x1E008, 0x1E018 },
+{ 0x1E01B, 0x1E021 },
+{ 0x1E023, 0x1E024 },
+{ 0x1E026, 0x1E02A },
{ 0x1E8D0, 0x1E8D6 },
+{ 0x1E944, 0x1E94A },
{ 0xE0001, 0xE0001 },
{ 0xE0020, 0xE007F },
{ 0xE0100, 0xE01EF }
};
static const struct interval double_width[] = {
-{ /* plane */ 0x0, 0x1C },
-{ /* plane */ 0x1C, 0x21 },
-{ /* plane */ 0x21, 0x22 },
-{ /* plane */ 0x22, 0x23 },
+{ /* plane */ 0x0, 0x3D },
+{ /* plane */ 0x3D, 0x68 },
+{ /* plane */ 0x68, 0x69 },
+{ /* plane */ 0x69, 0x6A },
{ /* plane */ 0x0, 0x0 },
{ /* plane */ 0x0, 0x0 },
{ /* plane */ 0x0, 0x0 },
@@ -286,7 +315,40 @@ static const struct interval double_width[] = {
{ /* plane */ 0x0, 0x0 },
{ /* plane */ 0x0, 0x0 },
{ 0x1100, 0x115F },
+{ 0x231A, 0x231B },
{ 0x2329, 0x232A },
+{ 0x23E9, 0x23EC },
+{ 0x23F0, 0x23F0 },
+{ 0x23F3, 0x23F3 },
+{ 0x25FD, 0x25FE },
+{ 0x2614, 0x2615 },
+{ 0x2648, 0x2653 },
+{ 0x267F, 0x267F },
+{ 0x2693, 0x2693 },
+{ 0x26A1, 0x26A1 },
+{ 0x26AA, 0x26AB },
+{ 0x26BD, 0x26BE },
+{ 0x26C4, 0x26C5 },
+{ 0x26CE, 0x26CE },
+{ 0x26D4, 0x26D4 },
+{ 0x26EA, 0x26EA },
+{ 0x26F2, 0x26F3 },
+{ 0x26F5, 0x26F5 },
+{ 0x26FA, 0x26FA },
+{ 0x26FD, 0x26FD },
+{ 0x2705, 0x2705 },
+{ 0x270A, 0x270B },
+{ 0x2728, 0x2728 },
+{ 0x274C, 0x274C },
+{ 0x274E, 0x274E },
+{ 0x2753, 0x2755 },
+{ 0x2757, 0x2757 },
+{ 0x2795, 0x2797 },
+{ 0x27B0, 0x27B0 },
+{ 0x27BF, 0x27BF },
+{ 0x2B1B, 0x2B1C },
+{ 0x2B50, 0x2B50 },
+{ 0x2B55, 0x2B55 },
{ 0x2E80, 0x2E99 },
{ 0x2E9B, 0x2EF3 },
{ 0x2F00, 0x2FD5 },
@@ -313,11 +375,49 @@ static const struct interval double_width[] = {
{ 0xFE68, 0xFE6B },
{ 0xFF01, 0xFF60 },
{ 0xFFE0, 0xFFE6 },
+{ 0x16FE0, 0x16FE0 },
+{ 0x17000, 0x187EC },
+{ 0x18800, 0x18AF2 },
{ 0x1B000, 0x1B001 },
+{ 0x1F004, 0x1F004 },
+{ 0x1F0CF, 0x1F0CF },
+{ 0x1F18E, 0x1F18E },
+{ 0x1F191, 0x1F19A },
{ 0x1F200, 0x1F202 },
-{ 0x1F210, 0x1F23A },
+{ 0x1F210, 0x1F23B },
{ 0x1F240, 0x1F248 },
{ 0x1F250, 0x1F251 },
+{ 0x1F300, 0x1F320 },
+{ 0x1F32D, 0x1F335 },
+{ 0x1F337, 0x1F37C },
+{ 0x1F37E, 0x1F393 },
+{ 0x1F3A0, 0x1F3CA },
+{ 0x1F3CF, 0x1F3D3 },
+{ 0x1F3E0, 0x1F3F0 },
+{ 0x1F3F4, 0x1F3F4 },
+{ 0x1F3F8, 0x1F43E },
+{ 0x1F440, 0x1F440 },
+{ 0x1F442, 0x1F4FC },
+{ 0x1F4FF, 0x1F53D },
+{ 0x1F54B, 0x1F54E },
+{ 0x1F550, 0x1F567 },
+{ 0x1F57A, 0x1F57A },
+{ 0x1F595, 0x1F596 },
+{ 0x1F5A4, 0x1F5A4 },
+{ 0x1F5FB, 0x1F64F },
+{ 0x1F680, 0x1F6C5 },
+{ 0x1F6CC, 0x1F6CC },
+{ 0x1F6D0, 0x1F6D2 },
+{ 0x1F6EB, 0x1F6EC },
+{ 0x1F6F4, 0x1F6F6 },
+{ 0x1F910, 0x1F91E },
+{ 0x1F920, 0x1F927 },
+{ 0x1F930, 0x1F930 },
+{ 0x1F933, 0x1F93E },
+{ 0x1F940, 0x1F94B },
+{ 0x1F950, 0x1F95E },
+{ 0x1F980, 0x1F991 },
+{ 0x1F9C0, 0x1F9C0 },
{ 0x20000, 0x2FFFD },
{ 0x30000, 0x3FFFD }
};
--
2.7.2
^ permalink raw reply related
* [PATCH 1/2] update-unicode.sh: automatically download newer definition files
From: Beat Bolli @ 2016-12-02 21:26 UTC (permalink / raw)
To: git; +Cc: Beat Bolli
Checking just for the files' existence is not enough; we should also
download them if a newer version exists on the Unicode servers.
Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
update_unicode.sh | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/update_unicode.sh b/update_unicode.sh
index 27af77c..3c84270 100755
--- a/update_unicode.sh
+++ b/update_unicode.sh
@@ -10,12 +10,8 @@ if ! test -d unicode; then
mkdir unicode
fi &&
( cd unicode &&
- if ! test -f UnicodeData.txt; then
- wget http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
- fi &&
- if ! test -f EastAsianWidth.txt; then
- wget http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt
- fi &&
+ wget -N http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt \
+ http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt &&
if ! test -d uniset; then
git clone https://github.com/depp/uniset.git
fi &&
--
2.7.2
^ permalink raw reply related
* Re: [PATCH v6 1/6] submodules: add helper functions to determine presence of submodules
From: Jacob Keller @ 2016-12-02 21:31 UTC (permalink / raw)
To: Stefan Beller
Cc: Brandon Williams, Jeff King, Junio C Hamano, git@vger.kernel.org,
Jonathan Tan
In-Reply-To: <CAGZ79kYPpc0=NAJaNPW+8faszOPAkq=b3m-EopY5A8oFwh+9=g@mail.gmail.com>
On Fri, Dec 2, 2016 at 11:28 AM, Stefan Beller <sbeller@google.com> wrote:
> On Fri, Dec 2, 2016 at 11:20 AM, Jacob Keller <jacob.keller@gmail.com> wrote:
>>>
>>> So is there a reason why the library function realpath() can't be used?
>>> From a cursory look at its man page it seems to do the symlink
>>> resolution.
>>>
>>> --
>>> Brandon Williams
>>
>> I believe it uses the same method and thus wouldn't actually resolve
>> the issue. But I'm not really 100% sure on this.
>>
>> Thanks,
>> Jake
>
> I just reviewed 2 libc implementations (glibc and an Android libc) and
> both of them
> do not use chdir internally, but use readlink and compose the path 'manually'
> c.f. http://osxr.org:8080/glibc/source/stdlib/canonicalize.c?v=glibc-2.13
Interesting. Would this be portable to Windows, though?
Thanks,
Jake
^ permalink raw reply
* [PATCH] worktree: mark a file-local symbol with static
From: Ramsay Jones @ 2016-12-02 20:55 UTC (permalink / raw)
To: Stefan Beller; +Cc: Junio C Hamano, GIT Mailing-list
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
Hi Stefan,
If you need to re-roll your 'sb/submodule-intern-gitdir'
branch, could you please squash something similar to this
into the relevant patch (commit 2529715dc, "worktree: get
worktrees from submodules", 01-12-2016).
[This is based on pu; ie. on top of merge 86c7f863a, where
Junio as added the 'flags' parameter.]
Thanks!
ATB,
Ramsay Jones
worktree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/worktree.c b/worktree.c
index d5c71095e..ba393fe5c 100644
--- a/worktree.c
+++ b/worktree.c
@@ -168,7 +168,7 @@ static int compare_worktree(const void *a_, const void *b_)
return fspathcmp((*a)->path, (*b)->path);
}
-struct worktree **get_worktrees_internal(const char *git_common_dir, unsigned flags)
+static struct worktree **get_worktrees_internal(const char *git_common_dir, unsigned flags)
{
struct worktree **list = NULL;
struct strbuf path = STRBUF_INIT;
--
2.11.0
^ permalink raw reply related
* [PATCH 1/4] shallow.c: make paint_alloc slightly more robust
From: Rasmus Villemoes @ 2016-12-02 20:31 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy, Jeff King,
Rasmus Villemoes
I have no idea if this is a real issue, but it's not obvious to me that
paint_alloc cannot be called with info->nr_bits greater than about
4M (\approx 8*COMMIT_SLAB_SIZE). In that case the new slab would be too
small. So just round up the allocation to the maximum of
COMMIT_SLAB_SIZE and size.
Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
---
shallow.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/shallow.c b/shallow.c
index 4d0b005..e21534a 100644
--- a/shallow.c
+++ b/shallow.c
@@ -445,11 +445,13 @@ static uint32_t *paint_alloc(struct paint_info *info)
unsigned size = nr * sizeof(uint32_t);
void *p;
if (!info->slab_count || info->free + size > info->end) {
+ unsigned alloc_size = size < COMMIT_SLAB_SIZE ?
+ COMMIT_SLAB_SIZE : size;
info->slab_count++;
REALLOC_ARRAY(info->slab, info->slab_count);
- info->free = xmalloc(COMMIT_SLAB_SIZE);
+ info->free = xmalloc(alloc_size);
info->slab[info->slab_count - 1] = info->free;
- info->end = info->free + COMMIT_SLAB_SIZE;
+ info->end = info->free + alloc_size;
}
p = info->free;
info->free += size;
--
2.1.4
^ permalink raw reply related
* [PATCH 4/4] shallow.c: remove useless test
From: Rasmus Villemoes @ 2016-12-02 20:31 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy, Jeff King,
Rasmus Villemoes
In-Reply-To: <1480710664-26290-1-git-send-email-rv@rasmusvillemoes.dk>
It seems to be odd to do x=y if x==y. Maybe there's a bug somewhere near
this, but as is this is somewhat confusing.
Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
---
shallow.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shallow.c b/shallow.c
index 5aec5a5..7c28239 100644
--- a/shallow.c
+++ b/shallow.c
@@ -513,7 +513,7 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
p->item);
if (p->item->object.flags & SEEN)
continue;
- if (*p_refs == NULL || *p_refs == *refs)
+ if (*p_refs == NULL)
*p_refs = *refs;
commit_list_insert(p->item, &head);
}
--
2.1.4
^ permalink raw reply related
* [PATCH 3/4] shallow.c: bit manipulation tweaks
From: Rasmus Villemoes @ 2016-12-02 20:31 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy, Jeff King,
Rasmus Villemoes
In-Reply-To: <1480710664-26290-1-git-send-email-rv@rasmusvillemoes.dk>
First of all, 1 << 31 is technically undefined behaviour, so let's just
use an unsigned literal.
If i is 'signed int' and gcc doesn't know that i is positive, gcc
generates code to compute the C99-mandated values of "i / 32" and "i %
32", which is a lot more complicated than simple a simple shifts/mask.
The only caller of paint_down actually passes an "unsigned int" value,
but the prototype of paint_down causes (completely well-defined)
conversion to signed int, and gcc has no way of knowing that the
converted value is non-negative. Just make the id parameter unsigned.
In update_refstatus, the change in generated code is much smaller,
presumably because gcc is smart enough to see that i starts as 0 and is
only incremented, so it is allowed (per the UD of signed overflow) to
assume that i is always non-negative. But let's just help less smart
compilers generate good code anyway.
Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
---
shallow.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/shallow.c b/shallow.c
index 8b1c35d..5aec5a5 100644
--- a/shallow.c
+++ b/shallow.c
@@ -464,7 +464,7 @@ static uint32_t *paint_alloc(struct paint_info *info)
* all walked commits.
*/
static void paint_down(struct paint_info *info, const unsigned char *sha1,
- int id)
+ unsigned int id)
{
unsigned int i, nr;
struct commit_list *head = NULL;
@@ -476,7 +476,7 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
if (!c)
return;
memset(bitmap, 0, bitmap_size);
- bitmap[id / 32] |= (1 << (id % 32));
+ bitmap[id / 32] |= (1U << (id % 32));
commit_list_insert(c, &head);
while (head) {
struct commit_list *p;
@@ -650,11 +650,11 @@ static int add_ref(const char *refname, const struct object_id *oid,
static void update_refstatus(int *ref_status, int nr, uint32_t *bitmap)
{
- int i;
+ unsigned int i;
if (!ref_status)
return;
for (i = 0; i < nr; i++)
- if (bitmap[i / 32] & (1 << (i % 32)))
+ if (bitmap[i / 32] & (1U << (i % 32)))
ref_status[i]++;
}
--
2.1.4
^ permalink raw reply related
* [PATCH 2/4] shallow.c: avoid theoretical pointer wrap-around
From: Rasmus Villemoes @ 2016-12-02 20:31 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy, Jeff King,
Rasmus Villemoes
In-Reply-To: <1480710664-26290-1-git-send-email-rv@rasmusvillemoes.dk>
The expression info->free+size is technically undefined behaviour in
exactly the case we want to test for. Moreover, the compiler is likely
to translate the expression to
(unsigned long)info->free + size > (unsigned long)info->end
where there's at least a theoretical chance that the LHS could wrap
around 0, giving a false negative.
This might as well be written using pointer subtraction avoiding these
issues.
Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
---
shallow.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/shallow.c b/shallow.c
index e21534a..8b1c35d 100644
--- a/shallow.c
+++ b/shallow.c
@@ -444,7 +444,7 @@ static uint32_t *paint_alloc(struct paint_info *info)
unsigned nr = (info->nr_bits + 31) / 32;
unsigned size = nr * sizeof(uint32_t);
void *p;
- if (!info->slab_count || info->free + size > info->end) {
+ if (!info->slab_count || size > info->end - info->free) {
unsigned alloc_size = size < COMMIT_SLAB_SIZE ?
COMMIT_SLAB_SIZE : size;
info->slab_count++;
--
2.1.4
^ permalink raw reply related
* [PATCH] t3600: remove useless redirect
From: Stefan Beller @ 2016-12-02 20:05 UTC (permalink / raw)
To: gitster; +Cc: git, bmwill, Stefan Beller
In the next line the `actual` is overwritten again, so no need to redirect
the output of checkout into that file.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
t/t3600-rm.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 14f0edca2b..6e587f956f 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -709,7 +709,7 @@ test_expect_success 'checking out a commit after submodule removal needs manual
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 &&
test_i18ngrep "^warning: unable to rmdir submod:" actual &&
git status -s submod >actual &&
--
2.10.2.613.g22f2156
^ 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