[RFC PATCH] hashmap API: introduce for_each_hashmap_entry() helper macro
There is common pattern to traverse a hashmap in git source code: hashmap_iter_init(map, ); while ((entry = hashmap_iter_next())) // do something with entry This patch introduces the for_each_hashmap_entry() macro for more simple and clean usage of this pattern. It encapsulates loop over a hashmap, some related variables and makes bypass of a hashmap more readable. This patch has not functioal changes, so behaviour still the same as before. Signed-off-by: Alexander Kuleshov <kuleshovm...@gmail.com> --- Documentation/technical/api-hashmap.txt | 5 + builtin/describe.c | 9 - config.c| 6 ++ hashmap.c | 7 ++- hashmap.h | 7 +++ submodule-config.c | 6 +- test-hashmap.c | 4 +--- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Documentation/technical/api-hashmap.txt b/Documentation/technical/api-hashmap.txt index ad7a5bd..4c49aaf 100644 --- a/Documentation/technical/api-hashmap.txt +++ b/Documentation/technical/api-hashmap.txt @@ -193,6 +193,11 @@ more entries. `hashmap_iter_first` is a combination of both (i.e. initializes the iterator and returns the first entry, if any). +`for_each_hashmap_entry`:: + + Allows iterate over entries of the given hashmap with the certain + type of entry. + `const char *strintern(const char *string)`:: `const void *memintern(const void *data, size_t len)`:: diff --git a/builtin/describe.c b/builtin/describe.c index 8a25abe..c678bbb 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -272,13 +272,12 @@ static void describe(const char *arg, int last_one) fprintf(stderr, _("searching to describe %s\n"), arg); if (!have_util) { - struct hashmap_iter iter; struct commit *c; - struct commit_name *n = hashmap_iter_first(, ); - for (; n; n = hashmap_iter_next()) { - c = lookup_commit_reference_gently(n->peeled, 1); + + for_each_hashmap_entry(, commit_name) { + c = lookup_commit_reference_gently(entry->peeled, 1); if (c) - c->util = n; + c->util = entry; } have_util = 1; } diff --git a/config.c b/config.c index 7ddb287..c4b09ad 100644 --- a/config.c +++ b/config.c @@ -1382,16 +1382,14 @@ void git_configset_init(struct config_set *cs) void git_configset_clear(struct config_set *cs) { - struct config_set_element *entry; - struct hashmap_iter iter; if (!cs->hash_initialized) return; - hashmap_iter_init(>config_hash, ); - while ((entry = hashmap_iter_next())) { + for_each_hashmap_entry(>config_hash, config_set_element) { free(entry->key); string_list_clear(>value_list, 1); } + hashmap_free(>config_hash, 1); cs->hash_initialized = 0; free(cs->list.items); diff --git a/hashmap.c b/hashmap.c index b10b642..0574326 100644 --- a/hashmap.c +++ b/hashmap.c @@ -140,11 +140,8 @@ void hashmap_free(struct hashmap *map, int free_entries) if (!map || !map->table) return; if (free_entries) { - struct hashmap_iter iter; - struct hashmap_entry *e; - hashmap_iter_init(map, ); - while ((e = hashmap_iter_next())) - free(e); + for_each_hashmap_entry(map, hashmap_entry) + free(entry); } free(map->table); memset(map, 0, sizeof(*map)); diff --git a/hashmap.h b/hashmap.h index ab7958a..b8b158c 100644 --- a/hashmap.h +++ b/hashmap.h @@ -95,4 +95,11 @@ static inline const char *strintern(const char *string) return memintern(string, strlen(string)); } +#define for_each_hashmap_entry(map, type) \ + struct type *entry; \ + struct hashmap_iter iter; \ + \ + hashmap_iter_init(map, ); \ + while ((entry = hashmap_iter_next())) + #endif diff --git a/submodule-config.c b/submodule-config.c index b82d1fb..4be2812 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -65,16 +65,12 @@ static void free_one_config(struct submodule_entry *entry) static void cache_free(struct submodule_cache *cache) { - struct hashmap_iter iter; - struct submodule_entry *entry; - /* * We iterate over the name hash here to be symmetric with the * allocation of struct submodule entries. Each is allocated by * their .gitmodule blob sha1 and submo
[PATCH] help.c: strip suffix only if the STRIP_EXTENSION defined
We stripping extension in the list_commands_in_dir() to get commands without '.exe' suffix. Let's do it only if STRIP_EXTENSION is defined to not spend time for unnecessary strip_suffix() call in this case. Signed-off-by: Alexander Kuleshov <kuleshovm...@gmail.com> --- help.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/help.c b/help.c index 19328ea..c865991 100644 --- a/help.c +++ b/help.c @@ -153,8 +153,9 @@ static void list_commands_in_dir(struct cmdnames *cmds, continue; entlen = strlen(ent); - strip_suffix(ent, ".exe", ); - +#ifdef STRIP_EXTENSION + strip_suffix(ent, STRIP_EXTENSION, ); +#endif add_cmdname(cmds, ent, entlen); } closedir(dir); -- 2.8.0.rc2.216.g1477fb2.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] hashmap API: introduce for_each_hashmap_entry() helper macro
There is common pattern to traverse a hashmap in git source code: hashmap_iter_init(map, ); while ((entry = hashmap_iter_next())) // do something with entry This patch introduces the for_each_hashmap_entry() macro for more simple and clean usage of this pattern. It encapsulates loop over a hashmap and makes bypass of a hashmap more readable. This patch has not functioal changes, so behaviour still the same as before. Signed-off-by: Alexander Kuleshov <kuleshovm...@gmail.com> --- Documentation/technical/api-hashmap.txt | 5 + builtin/describe.c | 5 +++-- config.c| 7 --- hashmap.c | 8 hashmap.h | 4 submodule-config.c | 3 +-- test-hashmap.c | 4 ++-- 7 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Documentation/technical/api-hashmap.txt b/Documentation/technical/api-hashmap.txt index ad7a5bd..7cb7d2a 100644 --- a/Documentation/technical/api-hashmap.txt +++ b/Documentation/technical/api-hashmap.txt @@ -193,6 +193,11 @@ more entries. `hashmap_iter_first` is a combination of both (i.e. initializes the iterator and returns the first entry, if any). +`for_each_hashmap_entry`:: + + Allows iterate over entries of the given map with the given entry + and iterator. + `const char *strintern(const char *string)`:: `const void *memintern(const void *data, size_t len)`:: diff --git a/builtin/describe.c b/builtin/describe.c index 8a25abe..50e3377 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -274,8 +274,9 @@ static void describe(const char *arg, int last_one) if (!have_util) { struct hashmap_iter iter; struct commit *c; - struct commit_name *n = hashmap_iter_first(, ); - for (; n; n = hashmap_iter_next()) { + struct commit_name *n; + + for_each_hashmap_entry(, n, ) { c = lookup_commit_reference_gently(n->peeled, 1); if (c) c->util = n; diff --git a/config.c b/config.c index 7ddb287..392d5a2 100644 --- a/config.c +++ b/config.c @@ -1382,16 +1382,17 @@ void git_configset_init(struct config_set *cs) void git_configset_clear(struct config_set *cs) { - struct config_set_element *entry; struct hashmap_iter iter; + struct config_set_element *entry; + if (!cs->hash_initialized) return; - hashmap_iter_init(>config_hash, ); - while ((entry = hashmap_iter_next())) { + for_each_hashmap_entry(>config_hash, entry, ) { free(entry->key); string_list_clear(>value_list, 1); } + hashmap_free(>config_hash, 1); cs->hash_initialized = 0; free(cs->list.items); diff --git a/hashmap.c b/hashmap.c index b10b642..c41c12b 100644 --- a/hashmap.c +++ b/hashmap.c @@ -141,10 +141,10 @@ void hashmap_free(struct hashmap *map, int free_entries) return; if (free_entries) { struct hashmap_iter iter; - struct hashmap_entry *e; - hashmap_iter_init(map, ); - while ((e = hashmap_iter_next())) - free(e); + struct hashmap_entry *entry; + + for_each_hashmap_entry(map, entry, ) + free(entry); } free(map->table); memset(map, 0, sizeof(*map)); diff --git a/hashmap.h b/hashmap.h index ab7958a..772caf2 100644 --- a/hashmap.h +++ b/hashmap.h @@ -95,4 +95,8 @@ static inline const char *strintern(const char *string) return memintern(string, strlen(string)); } +#define for_each_hashmap_entry(map, entry, iter) \ + for (entry = hashmap_iter_first(map, iter); entry; \ +entry = hashmap_iter_next(iter)) + #endif diff --git a/submodule-config.c b/submodule-config.c index b82d1fb..5a8d7fa 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -73,8 +73,7 @@ static void cache_free(struct submodule_cache *cache) * allocation of struct submodule entries. Each is allocated by * their .gitmodule blob sha1 and submodule name. */ - hashmap_iter_init(>for_name, ); - while ((entry = hashmap_iter_next())) + for_each_hashmap_entry(>for_name, entry, ) free_one_config(entry); hashmap_free(>for_path, 1); diff --git a/test-hashmap.c b/test-hashmap.c index cc2891d..917d188 100644 --- a/test-hashmap.c +++ b/test-hashmap.c @@ -225,8 +225,8 @@ int main(int argc, char *argv[]) } else if (!strcmp("iterate", cmd)) { struct hashmap_iter iter; - hashmap_iter_init(, );
Re: [PATCH] help.c: strip suffix only if the STRIP_EXTENSION defined
Hello Jeff, On Wed, Mar 16, 2016 at 11:31 PM, Jeff Kingwrote: > This is billed as an optimization in the commit message, but these two > pieces of code are not the same. The original always strips ".exe", > whether or not STRIP_EXTENSION is defined, and whether or not it is > ".exe". > > In practice it works out because people on Unix systems do not have > "git-foo.exe", and nobody sets STRIP_EXTENSION to other things. But I > tend to think this is an improvement in robustness. > > I also wonder if this should be sharing the strip_extension() helper > added in your 63ca1c0. Yes, I want to move strip_extension() (from 63ca1c0) to the git-compat-util.h and adapt/reuse it in the help.c. What do you think about this? Thank you. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] help.c: strip suffix only if the STRIP_EXTENSION defined
On Wed, Mar 16, 2016 at 8:47 PM, Duy Nguyen <pclo...@gmail.com> wrote: > On Wed, Mar 16, 2016 at 9:27 PM, Alexander Kuleshov > <kuleshovm...@gmail.com> wrote: >> We stripping extension in the list_commands_in_dir() to get >> commands without '.exe' suffix. Let's do it only if STRIP_EXTENSION >> is defined to not spend time for unnecessary strip_suffix() call in >> this case. > > Unless the time saving is significant, I'm against this change. It > makes it harder to spot compile bugs in #ifdef'd code that's only > active on Windows (imagine somebody renames "ent" or change its type). > If you can do something like strip_extension() in git.c, it's better. > Or maybe just refactor that function a bit and share it with help.c Yes, agree. Will think about this. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH] hashmap API: introduce for_each_hashmap_entry() helper macro
Hello Junio, On Thu, Mar 17, 2016 at 12:09 AM, Junio C Hamano <gits...@pobox.com> wrote: > Alexander Kuleshov <kuleshovm...@gmail.com> writes: > >> diff --git a/hashmap.h b/hashmap.h >> index ab7958a..b8b158c 100644 >> --- a/hashmap.h >> +++ b/hashmap.h >> @@ -95,4 +95,11 @@ static inline const char *strintern(const char *string) >> return memintern(string, strlen(string)); >> } >> >> +#define for_each_hashmap_entry(map, type)\ >> + struct type *entry; \ >> + struct hashmap_iter iter; \ >> + \ >> + hashmap_iter_init(map, ); \ >> + while ((entry = hashmap_iter_next())) >> + > > This is an easy way to introduce decl-after-statement, i.e. needs an > extra pair of {} around the thing. It also forbids the callers from > defining "entry" and "iter" as their own identifier outside the > scope of this macro and use them inside the block that is iterated > over by shadowing these two variables. > > Other than that, it looks like a good concept. The syntax however > needs more thought because of the above two issues, I think. Thanks for feedback. Will fix first issue and think about second. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3] submodule-config: use hashmap_iter_first()
The hashmap API provides hashmap_iter_first() helper for initialion and getting the first entry of a hashmap. Let's use it instead of doing initialization manually and then get the first entry. There are no functional changes, just cleanup. Signed-off-by: Alexander Kuleshov <kuleshovm...@gmail.com> Reviewed-by: Stefan Beller <sbel...@google.com> --- Changelog v3: commit message edited. submodule-config.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/submodule-config.c b/submodule-config.c index b82d1fb..8ac5031 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -405,8 +405,7 @@ static const struct submodule *config_from(struct submodule_cache *cache, struct hashmap_iter iter; struct submodule_entry *entry; - hashmap_iter_init(>for_name, ); - entry = hashmap_iter_next(); + entry = hashmap_iter_first(>for_name, ); if (!entry) return NULL; return entry->config; -- 2.8.0.rc2.216.g1477fb2.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] submodule-config: use hashmap_iter_first()
from the for simplification. Signed-off-by: Alexander Kuleshov <kuleshovm...@gmail.com> Reviewed-by: Stefan Beller <sbel...@google.com> --- Changelog: added missed Signof-off-by and function name fixed in the commit message. submodule-config.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/submodule-config.c b/submodule-config.c index b82d1fb..8ac5031 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -405,8 +405,7 @@ static const struct submodule *config_from(struct submodule_cache *cache, struct hashmap_iter iter; struct submodule_entry *entry; - hashmap_iter_init(>for_name, ); - entry = hashmap_iter_next(); + entry = hashmap_iter_first(>for_name, ); if (!entry) return NULL; return entry->config; -- 2.8.0.rc2.216.g1477fb2.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] submodule-config: use hashmap_iter_init()
On Wed, Mar 16, 2016 at 1:08 AM, Stefan Bellerwrote: > The change looks correct to me. But as Eric said, the commit message > needs work and a sign off. With that, > Reviewed-by: Stefan Beller Ah, yes, forgot to pass `-s` to commit command. Sorry for noise guys, will resend the patch. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] submodule-config: use hashmap_iter_init()
from the for simplification. --- submodule-config.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/submodule-config.c b/submodule-config.c index b82d1fb..8ac5031 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -405,8 +405,7 @@ static const struct submodule *config_from(struct submodule_cache *cache, struct hashmap_iter iter; struct submodule_entry *entry; - hashmap_iter_init(>for_name, ); - entry = hashmap_iter_next(); + entry = hashmap_iter_first(>for_name, ); if (!entry) return NULL; return entry->config; -- 2.8.0.rc2.216.g1477fb2.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] environment.c: introduce DECLARE_GIT_GETTER helper macro
The environment.c contans a couple of functions which are consist from the following pattern: if (!env) setup_git_env(); return env; Let's move declaration of these functions to the DECLARE_GIT_GETTER helper macro to prevent code duplication. Signed-off-by: Alexander Kuleshov <kuleshovm...@gmail.com> --- environment.c | 49 ++--- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/environment.c b/environment.c index 6dec9d0..f10fc7a 100644 --- a/environment.c +++ b/environment.c @@ -126,6 +126,14 @@ const char * const local_repo_env[] = { NULL }; +#define DECLARE_GIT_GETTER(type, name, env)\ + type name(void) \ + { \ + if (!env) \ + setup_git_env();\ + return env; \ + } + static char *expand_namespace(const char *raw_namespace) { struct strbuf buf = STRBUF_INIT; @@ -197,25 +205,11 @@ int is_bare_repository(void) return is_bare_repository_cfg && !get_git_work_tree(); } -const char *get_git_dir(void) -{ - if (!git_dir) - setup_git_env(); - return git_dir; -} - const char *get_git_common_dir(void) { return git_common_dir; } -const char *get_git_namespace(void) -{ - if (!namespace) - setup_git_env(); - return namespace; -} - const char *strip_namespace(const char *namespaced_ref) { if (!starts_with(namespaced_ref, get_git_namespace())) @@ -249,13 +243,6 @@ const char *get_git_work_tree(void) return work_tree; } -char *get_object_directory(void) -{ - if (!git_object_dir) - setup_git_env(); - return git_object_dir; -} - int odb_mkstemp(char *template, size_t limit, const char *pattern) { int fd; @@ -293,20 +280,6 @@ int odb_pack_keep(char *name, size_t namesz, const unsigned char *sha1) return open(name, O_RDWR|O_CREAT|O_EXCL, 0600); } -char *get_index_file(void) -{ - if (!git_index_file) - setup_git_env(); - return git_index_file; -} - -char *get_graft_file(void) -{ - if (!git_graft_file) - setup_git_env(); - return git_graft_file; -} - int set_git_dir(const char *path) { if (setenv(GIT_DIR_ENVIRONMENT, path, 1)) @@ -325,3 +298,9 @@ const char *get_commit_output_encoding(void) { return git_commit_encoding ? git_commit_encoding : "UTF-8"; } + +DECLARE_GIT_GETTER(const char *, get_git_dir, git_dir) +DECLARE_GIT_GETTER(const char *, get_git_namespace, namespace) +DECLARE_GIT_GETTER(char *, get_object_directory, git_object_dir) +DECLARE_GIT_GETTER(char *, get_index_file, git_index_file) +DECLARE_GIT_GETTER(char *, get_graft_file, git_graft_file) -- 2.8.0.rc0.142.g64f2103.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] environment.c: introduce SETUP_GIT_ENV helper macro
Hello Junio, On Sun, Feb 28, 2016 at 12:50 AM, Junio C Hamanowrote: > Junio C Hamano writes: > > >> Please don't. A macro that hides "return" makes things harder to >> follow, not easier. I will consider it next time. > Having said that, I do think a higher-level macro that encapulates > the whole thing may not be such a bad idea, i.e. making the above > into > > DECLARE_GIT_GETTER(const char *, get_git_dir, git_dir) Yes, it is better. Will resend the patch. Thank you. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] environment.c: introduce SETUP_GIT_ENV helper macro
The environment.c contans a couple of functions which are consist from the following pattern: if (!env) setup_git_env(); return env; Let's move this to the SETUP_GIT_ENV helper macro to prevent code duplication in these functions. Signed-off-by: Alexander Kuleshov <kuleshovm...@gmail.com> --- environment.c | 25 ++--- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/environment.c b/environment.c index 6dec9d0..04cb6cd 100644 --- a/environment.c +++ b/environment.c @@ -126,6 +126,11 @@ const char * const local_repo_env[] = { NULL }; +#define SETUP_GIT_ENV(env) \ + if (!env) \ + setup_git_env();\ + return env; + static char *expand_namespace(const char *raw_namespace) { struct strbuf buf = STRBUF_INIT; @@ -199,9 +204,7 @@ int is_bare_repository(void) const char *get_git_dir(void) { - if (!git_dir) - setup_git_env(); - return git_dir; + SETUP_GIT_ENV(git_dir); } const char *get_git_common_dir(void) @@ -211,9 +214,7 @@ const char *get_git_common_dir(void) const char *get_git_namespace(void) { - if (!namespace) - setup_git_env(); - return namespace; + SETUP_GIT_ENV(namespace); } const char *strip_namespace(const char *namespaced_ref) @@ -251,9 +252,7 @@ const char *get_git_work_tree(void) char *get_object_directory(void) { - if (!git_object_dir) - setup_git_env(); - return git_object_dir; + SETUP_GIT_ENV(git_object_dir); } int odb_mkstemp(char *template, size_t limit, const char *pattern) @@ -295,16 +294,12 @@ int odb_pack_keep(char *name, size_t namesz, const unsigned char *sha1) char *get_index_file(void) { - if (!git_index_file) - setup_git_env(); - return git_index_file; + SETUP_GIT_ENV(git_index_file); } char *get_graft_file(void) { - if (!git_graft_file) - setup_git_env(); - return git_graft_file; + SETUP_GIT_ENV(git_graft_file); } int set_git_dir(const char *path) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] git.c: simplify stripping extension of a file in handle_builtin()
The handle_builtin() starts from stripping of command extension if STRIP_EXTENSION is enabled. Actually STRIP_EXTENSION does not used anywhere else. This patch introduces strip_extension() helper to strip STRIP_EXTENSION extension from argv[0] with the strip_suffix() instead of manually stripping. Signed-off-by: Alexander Kuleshov <kuleshovm...@gmail.com> Helped-by: Jeff King <p...@peff.net> --- Changelog: v2: typos fixed in commit message. git-compat-util.h | 4 git.c | 26 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/git-compat-util.h b/git-compat-util.h index 8f0e76b..b35251c 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -333,10 +333,6 @@ extern char *gitdirname(char *); #define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin" #endif -#ifndef STRIP_EXTENSION -#define STRIP_EXTENSION "" -#endif - #ifndef has_dos_drive_prefix static inline int git_has_dos_drive_prefix(const char *path) { diff --git a/git.c b/git.c index 087ad31..6cc0c07 100644 --- a/git.c +++ b/git.c @@ -509,21 +509,25 @@ int is_builtin(const char *s) return !!get_builtin(s); } +#ifdef STRIP_EXTENSION +static void strip_extension(const char **argv) +{ + size_t len; + + if (strip_suffix(argv[0], STRIP_EXTENSION, )) + argv[0] = xmemdupz(argv[0], len); +} +#else +#define strip_extension(cmd) +#endif + static void handle_builtin(int argc, const char **argv) { - const char *cmd = argv[0]; - int i; - static const char ext[] = STRIP_EXTENSION; + const char *cmd; struct cmd_struct *builtin; - if (sizeof(ext) > 1) { - i = strlen(argv[0]) - strlen(ext); - if (i > 0 && !strcmp(argv[0] + i, ext)) { - char *argv0 = xstrdup(argv[0]); - argv[0] = cmd = argv0; - argv0[i] = '\0'; - } - } + strip_extension(argv); + cmd = argv[0]; /* Turn "git cmd --help" into "git help cmd" */ if (argc > 1 && !strcmp(argv[1], "--help")) { -- 2.7.1.339.g0233b80 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git.c: simplify striping extension of a file in handle_builtin()
The handle_builtin() starts from striping of command extension if STRIP_EXTENSION is enabled. Actually STRIP_EXTENSION does not used anywhere else. This patch introduces strip_extension() helper to strip STRIP_EXTENSION extension from argv[0] with the strip_suffix() instead of manually striping. Signed-off-by: Alexander Kuleshov <kuleshovm...@gmail.com> Helped-by: Jeff King <p...@peff.net> --- git-compat-util.h | 4 git.c | 26 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/git-compat-util.h b/git-compat-util.h index 8f0e76b..b35251c 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -333,10 +333,6 @@ extern char *gitdirname(char *); #define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin" #endif -#ifndef STRIP_EXTENSION -#define STRIP_EXTENSION "" -#endif - #ifndef has_dos_drive_prefix static inline int git_has_dos_drive_prefix(const char *path) { diff --git a/git.c b/git.c index 087ad31..6cc0c07 100644 --- a/git.c +++ b/git.c @@ -509,21 +509,25 @@ int is_builtin(const char *s) return !!get_builtin(s); } +#ifdef STRIP_EXTENSION +static void strip_extension(const char **argv) +{ + size_t len; + + if (strip_suffix(argv[0], STRIP_EXTENSION, )) + argv[0] = xmemdupz(argv[0], len); +} +#else +#define strip_extension(cmd) +#endif + static void handle_builtin(int argc, const char **argv) { - const char *cmd = argv[0]; - int i; - static const char ext[] = STRIP_EXTENSION; + const char *cmd; struct cmd_struct *builtin; - if (sizeof(ext) > 1) { - i = strlen(argv[0]) - strlen(ext); - if (i > 0 && !strcmp(argv[0] + i, ext)) { - char *argv0 = xstrdup(argv[0]); - argv[0] = cmd = argv0; - argv0[i] = '\0'; - } - } + strip_extension(argv); + cmd = argv[0]; /* Turn "git cmd --help" into "git help cmd" */ if (argc > 1 && !strcmp(argv[1], "--help")) { -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] git-compat-util.h: move extension stripping from handle_builtin()
Hello Jeff, On 02-20-16, Jeff King wrote: > On Sat, Feb 20, 2016 at 02:10:58PM +0600, Alexander Kuleshov wrote: > > I'm not convinced that moving the functions inline into git-compat-util > is actually cleaner. We've expanded the interface that is visible to the > whole code base, warts at all. > > One wart I see is that the caller cannot know whether the return value > was newly allocated or not, and therefore cannot free it, creating a > potential memory leak. Another is that the return value is not really > necessary at all; we always munge argv[0]. > > Does any other part of the code actually care about this > extension-stripping? Nope, only this one. > > Perhaps instead, could we do this: > If we drop this default-to-empty value of STRIP_EXTENSION entirely, then > we can do our #ifdef local to git.c, where it does not bother anybody > else. Like: > > #ifdef STRIP_EXTENSION > static void strip_extension(const char **argv) > { > /* Do the thing */ > } > #else > #define strip_extension(x) > #endif > > (Note that I also simplified the return value). > > In the case that we do have STRIP_EXTENSION, I don't think we need to > handle the empty-string case. It would be a regression for somebody > passing -DSTRIP_EXTENSION="", but I don't think that's worth worrying > about. That macro is defined totally internally. > > I suspect you could also use strip_suffix here. So something like: > > size_t len; > > if (strip_suffix(str, STRIP_EXTENSION, )) > argv[0] = xmemdupz(argv[0], len); > > would probably work, but that's totally untested. Good suggestion. I will try to do it and test. Thank you. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git-compat-util.h: move extension stripping from handle_builtin()
The handle_builtin() starts from striping of command extension if STRIP_EXTENSION is enabled. As this is an OS dependent, let's move to the git-compat-util.h as all similar functions to do handle_builtin() more cleaner. --- git-compat-util.h | 18 ++ git.c | 13 + 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/git-compat-util.h b/git-compat-util.h index 658d03b..57f2fda 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -323,6 +323,24 @@ extern char *gitbasename(char *); #ifndef STRIP_EXTENSION #define STRIP_EXTENSION "" +static inline const char *strip_extension(const char **argv) +{ + return argv[0]; +} +#else +static inline const char *strip_extension(const char **argv) +{ + static const char ext[] = STRIP_EXTENSION; + int ext_len = strlen(argv[0]) - strlen(ext); + + if (ext_len > 0 && !strcmp(argv[0] + ext_len, ext)) { + char *argv0 = xstrdup(argv[0]); + argv[0] = argv0; + argv0[ext_len] = '\0'; + } + + return argv[0]; +} #endif #ifndef has_dos_drive_prefix diff --git a/git.c b/git.c index 8751ef0..a4d2a46 100644 --- a/git.c +++ b/git.c @@ -506,19 +506,8 @@ int is_builtin(const char *s) static void handle_builtin(int argc, const char **argv) { - const char *cmd = argv[0]; - int i; - static const char ext[] = STRIP_EXTENSION; struct cmd_struct *builtin; - - if (sizeof(ext) > 1) { - i = strlen(argv[0]) - strlen(ext); - if (i > 0 && !strcmp(argv[0] + i, ext)) { - char *argv0 = xstrdup(argv[0]); - argv[0] = cmd = argv0; - argv0[i] = '\0'; - } - } + const char *cmd = strip_extension(argv); /* Turn "git cmd --help" into "git help cmd" */ if (argc > 1 && !strcmp(argv[1], "--help")) { -- 2.4.4.764.gf6c74eb.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] exec_cmd.c: use find_last_dir_sep() for code simplification
We are trying to extract dirname from argv0 in the git_extract_argv0_path(). But in the same time, the provides find_last_dir_sep() to get dirname from a given path. Let's use it instead of loop for the code simplification. Signed-off-by: Alexander Kuleshov <kuleshovm...@gmail.com> --- exec_cmd.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/exec_cmd.c b/exec_cmd.c index e85f0fd..680b257 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -43,12 +43,10 @@ const char *git_extract_argv0_path(const char *argv0) if (!argv0 || !*argv0) return NULL; - slash = argv0 + strlen(argv0); - while (argv0 <= slash && !is_dir_sep(*slash)) - slash--; + slash = find_last_dir_sep(argv0); - if (slash >= argv0) { + if (slash) { argv0_path = xstrndup(argv0, slash - argv0); return slash + 1; } -- 2.4.4.764.g5dbb725.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] commit: add commit.signoff config option
On 06/25, cmarc...@gmail.com wrote: From: Caio Marcelo de Oliveira Filho cmarc...@gmail.com In projects that use Signed-off-by, it's convenient to include that line in the commit by default. The commit.signoff config option allows to add that line in all commits automatically. Document that this config option can be overriden by using --no-signoff. Hello, also would be great to have bash completion for the --no-signoff Thank you. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] format-patch: introduce format.outputDirectory configuration
Hello Jeff and Junio, Thank you for feedback and help. I think also I need to add yet another test which tests case when configuration option is set and -o passed. I'll make changes and resend the patch. Thank you. 2015-06-19 10:14 GMT+06:00 Jeff King p...@peff.net: On Thu, Jun 18, 2015 at 02:46:36PM -0700, Junio C Hamano wrote: If I were designing from scratch, I would consider making -o - output to stdout, and letting it override a previous -o (or vice versa). We could still do that (and make --stdout an alias for that), but I don't know if it is worth the trouble (it does change the behavior for anybody who wanted a directory called -, but IMHO it is more likely to save somebody a headache than create one). I agree with later -o should override an earlier one, but I do not necessarily agree with '-o -' should be --stdout, for a simple reason that -o foo is not --stdout foo. Good point. At any rate, that was all in my designing from scratch hypothetical, so it is doubly not worth considering. Perhaps something like this to replace builtin/ part of Alexander's patch? [...] @@ -1337,6 +1342,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) die (_(--subject-prefix and -k are mutually exclusive.)); rev.preserve_subject = keep_subject; + if (!output_directory !use_stdout) + output_directory = config_output_directory; + Yeah, I think that is the sanest way to do it given the constraints. -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] format-patch: introduce format.outputDirectory configuration
2015-06-19 3:46 GMT+06:00 Junio C Hamano gits...@pobox.com: I agree with later -o should override an earlier one, but I do not necessarily agree with '-o -' should be --stdout, for a simple reason that -o foo is not --stdout foo. Perhaps something like this to replace builtin/ part of Alexander's patch? @@ -1337,6 +1342,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) die (_(--subject-prefix and -k are mutually exclusive.)); rev.preserve_subject = keep_subject; + if (!output_directory !use_stdout) + output_directory = config_output_directory; + But there is following condition above: if (!use_stdout) output_directory = set_outdir(prefix, output_directory); After which output_directory will be ./ everytime and + if (!output_directory !use_stdout) + output_directory = config_output_directory; + will not work here. What if we remove if (output_directory) {} and update it as: if (!use_stdout) { if (!config_output_directory !output_directory) output_directory = set_outdir(prefix, output_directory); else if (config_output_directory) output_directory = config_output_directory; if (mkdir(output_directory, 0777) 0 errno != EEXIST) die_errno(_(Could not create directory '%s'), output_directory); } else setup_pager(); ? -- To unsubscribe from this list: send the line unsubscribe git in
Re: [PATCH] format-patch: introduce format.outputDirectory configuration
I thought I made that if we did not see '-o dir' on the command line, initialize output_directory to what we read from the config before we make a call to set_outdir(). What I am missing? Puzzled... FWIW, IIRC, the patch you are responding to passed the test you added. Ok, Now we have: if (!use_stdout) output_directory = set_outdir(prefix, output_directory); else setup_pager(); and if (output_directory) { // test that we did not pass use_stdout and mkdir than } If we didn't pass --stdout and -o the set_outdir will be called and there is static const char *set_outdir(const char *prefix, const char *output_directory) { //printf(is_absoulte_path %d\n, is_absolute_path(output_directory)); if (output_directory is_absolute_path(output_directory)) return output_directory; if (!prefix || !*prefix) { if (output_directory) return output_directory; return ./; } } So it returns ./, output_directory will not be null. After this + if (!output_directory !use_stdout) + output_directory = config_output_directory; clause will not be executed never. Or I've missed something? Thank you. -- To unsubscribe from this list: send the line unsubscribe git in
Re: [PATCH] format-patch: introduce format.outputDirectory configuration
Ah, you mean to put this check before. Just tested it and many tests are broken. Will look on it now 2015-06-19 23:19 GMT+06:00 Alexander Kuleshov kuleshovm...@gmail.com: I thought I made that if we did not see '-o dir' on the command line, initialize output_directory to what we read from the config before we make a call to set_outdir(). What I am missing? Puzzled... FWIW, IIRC, the patch you are responding to passed the test you added. Ok, Now we have: if (!use_stdout) output_directory = set_outdir(prefix, output_directory); else setup_pager(); and if (output_directory) { // test that we did not pass use_stdout and mkdir than } If we didn't pass --stdout and -o the set_outdir will be called and there is static const char *set_outdir(const char *prefix, const char *output_directory) { //printf(is_absoulte_path %d\n, is_absolute_path(output_directory)); if (output_directory is_absolute_path(output_directory)) return output_directory; if (!prefix || !*prefix) { if (output_directory) return output_directory; return ./; } } So it returns ./, output_directory will not be null. After this + if (!output_directory !use_stdout) + output_directory = config_output_directory; clause will not be executed never. Or I've missed something? Thank you. -- To unsubscribe from this list: send the line unsubscribe git in
[PATCH v2] format-patch: introduce format.outputDirectory configuration
We can pass -o/--output-directory to the format-patch command to store patches not in the working directory. This patch introduces format.outputDirectory configuration option for same purpose. The case of usage of this configuration option can be convinience to not pass everytime -o/--output-directory if an user has pattern to store all patches in the /patches directory for example. The format.outputDirectory has lower priority than command line option, so if user will set format.outputDirectory and pass the command line option, a result will be stored in a directory that passed to command line option. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/config.txt | 4 Documentation/git-format-patch.txt | 6 +- builtin/log.c | 8 t/t4014-format-patch.sh| 18 ++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index e159fe5..4f991b6 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1262,6 +1262,10 @@ format.coverLetter:: format-patch is invoked, but in addition can be set to auto, to generate a cover-letter only when there's more than one patch. +format.outputDirectory:: + Set a custom directory to store the resulting files instead of the + current working directory. + filter.driver.clean:: The command which is used to convert the content of a worktree file to a blob upon checkin. See linkgit:gitattributes[5] for diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 0dac4e9..38ddd76 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -57,7 +57,11 @@ The names of the output files are printed to standard output, unless the `--stdout` option is specified. If `-o` is specified, output files are created in dir. Otherwise -they are created in the current working directory. +they are created in the current working directory. The default path +can be set with the seting 'format.outputDirectory' configuration option. +If `-o` is specified and 'format.outputDirectory' is set, output files +will be stored in a dir that passed to `-o`. When 'format.outputDirectory' +is set to get default behaviour back is to pass './' to the `-o`. By default, the subject of a single patch is [PATCH] followed by the concatenation of lines from the commit message up to the first blank diff --git a/builtin/log.c b/builtin/log.c index 78b3e2c..fc26360 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -688,6 +688,8 @@ enum { COVER_AUTO }; +static const char *config_output_directory = NULL; + static int git_format_config(const char *var, const char *value, void *cb) { if (!strcmp(var, format.headers)) { @@ -758,6 +760,9 @@ static int git_format_config(const char *var, const char *value, void *cb) config_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF; return 0; } + if (!strcmp(var, format.outputdirectory)) { + return git_config_string(config_output_directory, var, value); + } return git_log_config(var, value, cb); } @@ -1368,6 +1373,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) if (rev.show_notes) init_display_notes(rev.notes_opt); + if (!output_directory !use_stdout) + output_directory = config_output_directory; + if (!use_stdout) output_directory = set_outdir(prefix, output_directory); else diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 890db11..613e2cc 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -40,6 +40,24 @@ test_expect_success setup ' ' +test_expect_success format-patch format.outputDirectory option ' + git config format.outputDirectory patches/ + git format-patch master..side + cnt=$(ls | wc -l) + test $cnt = 3 + test_config format.outputDirectory patches/ + git config --unset format.outputDirectory +' + +test_expect_success format-patch format.outputDirectory overwritten with -o ' + rm -rf patches + git config format.outputDirectory patches/ + git format-patch master..side -o . + test_must_fail ls patches/ + test_config format.outputDirectory patches/ + git config --unset format.outputDirectory +' + test_expect_success format-patch --ignore-if-in-upstream ' git format-patch --stdout master..side patch0 -- 2.4.4.727.g5c3049e.dirty -- To unsubscribe from this list: send the line unsubscribe git in
[PATCH] format-patch: introduce format.outputDirectory configuration
We can pass -o/--output-directory to the format-patch command to store patches not in the working directory. This patch introduces format.outputDirectory configuration option for same purpose. The case of usage of this configuration option can be convinience to not pass everytime -o/--output-directory if an user has pattern to store all patches in the /patches directory for example. The format.outputDirectory has lower priority than command line option, so if user will set format.outputDirectory and pass the command line option, a result will be stored in a directory that passed to command line option. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/config.txt | 4 builtin/log.c| 14 -- t/t4014-format-patch.sh | 9 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index fd2036c..8f6f7ed 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1247,6 +1247,10 @@ format.coverLetter:: format-patch is invoked, but in addition can be set to auto, to generate a cover-letter only when there's more than one patch. +format.outputDirectory:: + Set a custom directory to store the resulting files instead of the + current working directory. + filter.driver.clean:: The command which is used to convert the content of a worktree file to a blob upon checkin. See linkgit:gitattributes[5] for diff --git a/builtin/log.c b/builtin/log.c index dfb351e..22c1e46 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -687,6 +687,8 @@ enum { COVER_AUTO }; +static const char *config_output_directory = NULL; + static int git_format_config(const char *var, const char *value, void *cb) { if (!strcmp(var, format.headers)) { @@ -757,6 +759,9 @@ static int git_format_config(const char *var, const char *value, void *cb) config_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF; return 0; } + if (!strcmp(var, format.outputdirectory)) { + return git_config_string(config_output_directory, var, value); + } return git_log_config(var, value, cb); } @@ -1006,7 +1011,8 @@ static const char *clean_message_id(const char *msg_id) return xmemdupz(a, z - a); } -static const char *set_outdir(const char *prefix, const char *output_directory) +static const char *set_outdir(const char *prefix, const char *output_directory, + const char *config_output_directory) { if (output_directory is_absolute_path(output_directory)) return output_directory; @@ -1014,6 +1020,9 @@ static const char *set_outdir(const char *prefix, const char *output_directory) if (!prefix || !*prefix) { if (output_directory) return output_directory; + + if (config_output_directory) + return config_output_directory; /* The user did not explicitly ask for ./ */ outdir_offset = 2; return ./; @@ -1368,7 +1377,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) init_display_notes(rev.notes_opt); if (!use_stdout) - output_directory = set_outdir(prefix, output_directory); + output_directory = set_outdir(prefix, output_directory, + config_output_directory); else setup_pager(); diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index c39e500..a4b18b5 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -40,6 +40,15 @@ test_expect_success setup ' ' +test_expect_success format-patch format.outputDirectory option ' + git config format.outputDirectory patches/ + git format-patch master..side + cnt=$(ls | wc -l) + echo $cnt + test $cnt = 3 + git config --unset format.outputDirectory +' + test_expect_success format-patch --ignore-if-in-upstream ' git format-patch --stdout master..side patch0 -- 2.4.0.383.gded6615.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] clean: describe --dry-run option in a more clear way in the usage string
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/clean.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/clean.c b/builtin/clean.c index 17a1c13..01aae96 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -891,7 +891,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) const char *qname; struct option options[] = { OPT__QUIET(quiet, N_(do not print names of files removed)), - OPT__DRY_RUN(dry_run, N_(dry run)), + OPT__DRY_RUN(dry_run, N_(do not remove anything, only show what would be removed)), OPT__FORCE(force, N_(force)), OPT_BOOL('i', interactive, interactive, N_(interactive cleaning)), OPT_BOOL('d', NULL, remove_directories, -- 2.4.0.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC] add: Do not open editor if patch is empty
If we'll run 'git add -e path' on a path which has no difference with the current index, empty editor will open. This patch prevents this behaviour and checks that patch is not empty before an editor with patch will be opened. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/add.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index ee370b0..4fc6b13 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -209,13 +209,13 @@ static int edit_patch(int argc, const char **argv, const char *prefix) if (run_diff_files(rev, 0)) die(_(Could not write patch)); - launch_editor(file, NULL, NULL); - if (stat(file, st)) die_errno(_(Could not stat '%s'), file); if (!st.st_size) die(_(Empty patch. Aborted.)); + launch_editor(file, NULL, NULL); + child.git_cmd = 1; child.argv = apply_argv; if (run_command(child)) -- 2.3.3.611.g09038fc.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC] init-db: introduce new -c/--config option
Hello All, I'm not sure about two things: 1. Is there any way to do this with the current git? At least i didn't find how to do it, so decided to write this patch. If there is already ability to do the same without this patch, please let me know. 2. Now current patch overwrite the value of the configuration option from config, if there is given option with the same key. For example, when we do git init, .git/config contains core.filemode = true. If we will pass core.filemode = false with this patch to git init, there will be core.filemode = false in the .git/config. So, I'm not sure about it. I looked on git clone -c/--config, it just adds the same option to the .git/config, but it looks strange to me So, I'm wating for any feedback. Thank you. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC] init-db: introduce new -c/--config option
For now we can clone repository with the `git clone` command and pass -c/--config with configuration option to it and these configuration options will be set in the clonned repository config. This patch provides the same functional, but for the `git init` command. It allows to pass -c/--config option to the `git init` command and given configuration option will be added to the newly created repository, after it will be created. This option can be used multiply times. If given configuration option is the same that in the default config, given option will overwrite. Main purpose of this option is to get rid of the manual editing of the config. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-init.txt | 11 ++- builtin/init-db.c | 33 +++-- t/t0001-init.sh| 16 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index 8174d27..3ecbf2a 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -10,7 +10,7 @@ SYNOPSIS [verse] 'git init' [-q | --quiet] [--bare] [--template=template_directory] - [--separate-git-dir git dir] + [--separate-git-dir git dir] [--config key=value] [--shared[=permissions]] [directory] @@ -111,6 +111,15 @@ into it. If you provide a 'directory', the command is run inside it. If this directory does not exist, it will be created. +--config key=value:: +-c key=value:: +Set a new configuration option in the new repository. The key expected in +the same format as linkgit:git-config[1] (e.g., `core.eol=true`). If +This option can be used multiply times. If multiply options are given with +the same keys, each value will be written to the config. If given key is +the same that used in the default configuration file, previous value +will be overwritten. + -- TEMPLATE DIRECTORY diff --git a/builtin/init-db.c b/builtin/init-db.c index 280454a..184de40 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -471,6 +471,26 @@ static const char *const init_db_usage[] = { NULL }; +static int write_one_config(const char *key, const char *value, void *data) { + char *v = NULL; + git_config_get_string(key, v); + if (v) { + git_config_set(key, value); + return 1 + } else + return git_config_set_multivar(key, value ? value : true, ^$, 0); +} + +static void write_config(struct string_list *config){ + int i; + + for (i = 0; i config-nr; i++) { + if (git_config_parse_parameter(config-items[i].string, + write_one_config, NULL) 0) + die(unable to write parameters to config file); + } +} + /* * If you want to, you can share the DB area with any number of branches. * That has advantages: you can save space by sharing all the SHA1 objects. @@ -479,11 +499,13 @@ static const char *const init_db_usage[] = { */ int cmd_init_db(int argc, const char **argv, const char *prefix) { + int ret; const char *git_dir; const char *real_git_dir = NULL; const char *work_tree; const char *template_dir = NULL; unsigned int flags = 0; + static struct string_list option_config; const struct option init_db_options[] = { OPT_STRING(0, template, template_dir, N_(template-directory), N_(directory from which templates will be used)), @@ -496,6 +518,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) OPT_BIT('q', quiet, flags, N_(be quiet), INIT_DB_QUIET), OPT_STRING(0, separate-git-dir, real_git_dir, N_(gitdir), N_(separate git dir from working tree)), + OPT_STRING_LIST('c', config, option_config, N_(key=value), + N_(set config inside the new repository)), OPT_END() }; @@ -592,6 +616,11 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) } set_git_dir_init(git_dir, real_git_dir, 1); - - return init_db(template_dir, flags); + ret = init_db(template_dir, flags); + /* +* new repository already created, so we can update .git/config if +* -c/--config passed +*/ + write_config(option_config); + return ret; } diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 7de8d85..8ce3537 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -339,4 +339,20 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' ' test_path_is_dir realgitdir/refs ' +test_expect_success 'git init -c key=value' ' + rm -rf newdir realgitdir + git init -c core.foo=bar newdir + echo bar expect + git --git-dir=newdir/.git config core.foo actual + test_cmp expect
Re: [PATCH RFC 1/3] add: add new --exclude option to git add
Isn't the problem one of how are users to discover such magic. Yes it was main reason. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH RFC 1/3] add: add new --exclude option to git add
This patch introduces new --exclude option for the git add command. We already have core.excludesfile configuration variable which indicates a path to file which contains patterns to exclude. This patch provides ability to pass --exclude option to the git add command to exclude paths from command line in addition to which found in the ignore files. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/add.c | 20 1 file changed, 20 insertions(+) diff --git a/builtin/add.c b/builtin/add.c index 3390933..5c602a6 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -244,6 +244,16 @@ static int ignore_removal_cb(const struct option *opt, const char *arg, int unse return 0; } +struct string_list exclude_list = STRING_LIST_INIT_NODUP; +struct exclude_list *el; + +static int exclude_cb(const struct option *opt, const char *arg, int unset) +{ + struct string_list *exclude_list = opt-value; + string_list_append(exclude_list, arg); + return 0; +} + static struct option builtin_add_options[] = { OPT__DRY_RUN(show_only, N_(dry run)), OPT__VERBOSE(verbose, N_(be verbose)), @@ -255,6 +265,9 @@ static struct option builtin_add_options[] = { OPT_BOOL('u', update, take_worktree_changes, N_(update tracked files)), OPT_BOOL('N', intent-to-add, intent_to_add, N_(record only the fact that the path will be added later)), OPT_BOOL('A', all, addremove_explicit, N_(add changes from all tracked and untracked files)), + { OPTION_CALLBACK, 0, exclude, exclude_list, N_(pattern), + N_(do no add files matching pattern to index), + 0, exclude_cb }, { OPTION_CALLBACK, 0, ignore-removal, addremove_explicit, NULL /* takes no arguments */, N_(ignore paths removed in the working tree (same as --no-all)), @@ -298,6 +311,7 @@ static int add_files(struct dir_struct *dir, int flags) int cmd_add(int argc, const char **argv, const char *prefix) { + int i; int exit_status = 0; struct pathspec pathspec; struct dir_struct dir; @@ -381,6 +395,11 @@ int cmd_add(int argc, const char **argv, const char *prefix) if (!ignored_too) { dir.flags |= DIR_COLLECT_IGNORED; setup_standard_excludes(dir); + + el = add_exclude_list(dir, EXC_CMDL, --exclude option); + for (i = 0; i exclude_list.nr; i++) + add_exclude(exclude_list.items[i].string, , 0, el, -(i+1)); + } memset(empty_pathspec, 0, sizeof(empty_pathspec)); @@ -446,5 +465,6 @@ finish: die(_(Unable to write new index file)); } + string_list_clear(exclude_list, 0); return exit_status; } -- 2.3.3.472.g20ceeac -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] t3700-add: added test for --exclude option
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- t/t3700-add.sh | 7 +++ 1 file changed, 7 insertions(+) diff --git a/t/t3700-add.sh b/t/t3700-add.sh index f7ff1f5..c52a5d0 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -81,6 +81,13 @@ test_expect_success '.gitignore is honored' ' ! (git ls-files | grep \\.ig) ' +test_expect_success 'Test that git add --exclude works' ' + touch foo + touch bar + git add --exclude=bar . + ! (git ls-files | grep bar) +' + test_expect_success 'error out when attempting to add ignored ones without -f' ' test_must_fail git add a.?? ! (git ls-files | grep \\.ig) -- 2.3.3.472.g20ceeac -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] Documentation/git-add.txt: describe --exclude option
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-add.txt | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index f2eb907..4bc156a 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -9,7 +9,7 @@ SYNOPSIS [verse] 'git add' [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p] - [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] + [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] [--exclude=pattern] [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--] [pathspec...] @@ -164,6 +164,10 @@ for git add --no-all pathspec..., i.e. ignored removed files. be ignored, no matter if they are already present in the work tree or not. +--exclude=pattern:: + Do not add files to the index in addition which are found in + the .gitignore. + \--:: This option can be used to separate command-line options from the list of files, (useful when filenames might be mistaken -- 2.3.3.472.g20ceeac -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] git.c: two memory leak fixes
Hello Junio, This is technically correct, but do we really care about it? Yes, as i saw handle_alias called once, and we no need to care about it. I think it is wrong to free alias_string after passing it to split_cmdline() and while you still need to use the new_argv. Yes, right. sorry for the noise. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC 1/3] add: add new --exclude option to git add
Hello All, s /no/not/ ?? Thank you Philip. 2015-03-15 23:51 GMT+06:00 Torsten Bögershausen tbo...@web.de: On 2015-03-15 14.49, Alexander Kuleshov wrote: Thanks for working on Git, some minor remarks/suggestions inline. This patch introduces new --exclude option for the git add command. This patch is redundant. Shorter may be: Introduce the --exclude option for git add Thank you Torsten for you feedback. I will make all fixes and resend patch. One little question, how to better resend it? Just send v2 for the 1/3 or resend all with v2? Or maybe will be better to make one patch from these 3 pathes? Thank you. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3 v2] Documentation/git-add.txt: describe --exclude option
Helped-by: Eric Sunshine sunsh...@sunshineco.com Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-add.txt | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index f2eb907..fee97ed 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -9,7 +9,7 @@ SYNOPSIS [verse] 'git add' [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p] - [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] + [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] [--exclude=pattern] [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--] [pathspec...] @@ -164,6 +164,10 @@ for git add --no-all pathspec..., i.e. ignored removed files. be ignored, no matter if they are already present in the work tree or not. +--exclude=pattern:: + Also ignore files matching pattern, a .gitignore-like + pattern. Option can be used multiply times. + \--:: This option can be used to separate command-line options from the list of files, (useful when filenames might be mistaken -- 2.3.3.472.g20ceeac.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3 v2] t3700-add: added test for --exclude option
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- t/t3700-add.sh | 18 ++ 1 file changed, 18 insertions(+) diff --git a/t/t3700-add.sh b/t/t3700-add.sh index f7ff1f5..6f71c67 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -332,4 +332,22 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out test_i18ncmp expect.err actual.err ' +test_expect_success 'Test that git add --exclude works' ' + foo + bar + git add --exclude=bar . + ! (git ls-files | grep bar) + (git ls-files | grep foo) +' + +test_expect_success 'Test multiply --exclude' ' + foo + bar + b a z + git add --exclude=bar --exclude=b a z . + (git ls-files | grep foo) + ! (git ls-files | grep b a z) + ! (git ls-files | grep baz) +' + test_done -- 2.3.3.472.g20ceeac.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3 v2] add: introduce new --exclude option
We already have core.excludesfile configuration variable which indicates a path to file which contains patterns to exclude. This patch provides ability to pass --exclude option to the git add command to exclude paths from command line in addition to which specified in the ignore files. This option can be useful in a case when we have a directory with some *.ext files which have changes and we want to commit all files besides one for now. It can be too annoying to touch .gitignore for this. Helped-by: Eric Sunshine sunsh...@sunshineco.com Helped-by: Torsten Bögershausen tbo...@web.de Helped-by: Philip Oakley philipoak...@iee.org Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/add.c | 12 1 file changed, 12 insertions(+) diff --git a/builtin/add.c b/builtin/add.c index 3390933..e165fbc 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -244,6 +244,8 @@ static int ignore_removal_cb(const struct option *opt, const char *arg, int unse return 0; } +static struct string_list exclude_list = STRING_LIST_INIT_NODUP; + static struct option builtin_add_options[] = { OPT__DRY_RUN(show_only, N_(dry run)), OPT__VERBOSE(verbose, N_(be verbose)), @@ -255,6 +257,8 @@ static struct option builtin_add_options[] = { OPT_BOOL('u', update, take_worktree_changes, N_(update tracked files)), OPT_BOOL('N', intent-to-add, intent_to_add, N_(record only the fact that the path will be added later)), OPT_BOOL('A', all, addremove_explicit, N_(add changes from all tracked and untracked files)), + OPT_STRING_LIST(0, exclude, exclude_list, N_(pattern), + N_(do not add files matching pattern to index)), { OPTION_CALLBACK, 0, ignore-removal, addremove_explicit, NULL /* takes no arguments */, N_(ignore paths removed in the working tree (same as --no-all)), @@ -305,6 +309,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) int add_new_files; int require_pathspec; char *seen = NULL; + struct exclude_list *el; git_config(add_config, NULL); @@ -379,8 +384,14 @@ int cmd_add(int argc, const char **argv, const char *prefix) /* Set up the default git porcelain excludes */ memset(dir, 0, sizeof(dir)); if (!ignored_too) { + int i; dir.flags |= DIR_COLLECT_IGNORED; setup_standard_excludes(dir); + + el = add_exclude_list(dir, EXC_CMDL, --exclude option); + for (i = 0; i exclude_list.nr; i++) + add_exclude(exclude_list.items[i].string, , 0, el, -(i+1)); + } memset(empty_pathspec, 0, sizeof(empty_pathspec)); @@ -446,5 +457,6 @@ finish: die(_(Unable to write new index file)); } + string_list_clear(exclude_list, 0); return exit_status; } -- 2.3.3.472.g20ceeac.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git.c: two memory leak fixes
This patch provides fixes for two minor memory leaks in the handle_alias function: 1. We allocate memory for alias_argv with the xmalloc function call, after run_command_v_opt function will be executed we no need in this variable anymore, so let's free it. 2. Memory allocated for alias_string variable in the alias_lookup function, need to free it. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- git.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git.c b/git.c index 086fac1..501e5bd 100644 --- a/git.c +++ b/git.c @@ -252,6 +252,7 @@ static int handle_alias(int *argcp, const char ***argv) alias_argv[argc] = NULL; ret = run_command_v_opt(alias_argv, RUN_USING_SHELL); + free(alias_argv); if (ret = 0) /* normal exit */ exit(ret); @@ -259,6 +260,7 @@ static int handle_alias(int *argcp, const char ***argv) alias_command, alias_string + 1); } count = split_cmdline(alias_string, new_argv); + free(alias_string); if (count 0) die(Bad alias.%s string: %s, alias_command, split_cmdline_strerror(count)); -- 2.3.3.469.g69a3822.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] Documentation/git-hash-object.txt: add verbose option for hash-object
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-hash-object.txt | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt index 02c1f12..efec7c6 100644 --- a/Documentation/git-hash-object.txt +++ b/Documentation/git-hash-object.txt @@ -9,8 +9,8 @@ git-hash-object - Compute object ID and optionally creates a blob from a file SYNOPSIS [verse] -'git hash-object' [-t type] [-w] [--path=file|--no-filters] [--stdin] [--] file... -'git hash-object' [-t type] [-w] --stdin-paths [--no-filters] list-of-paths +'git hash-object' [-t type] [-w] [-v] [--path=file|--no-filters] [--stdin] [--] file... +'git hash-object' [-t type] [-w] [-v] --stdin-paths [--no-filters] list-of-paths DESCRIPTION --- @@ -31,6 +31,9 @@ OPTIONS -w:: Actually write the object into the object database. +-v:: + Prints file path near the hash. + --stdin:: Read the object from standard input instead of from a file. -- 2.3.1.167.g7f4ba4b.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git: make was_alias and done_help non-static
'was_alias' variable does not need to store it's value on each iteration in the loop, anyway this variable changes it's value with run_argv. 'done_help' variable does not need to be static variable too if we'll move it out the loop. So these variables do not need to be static. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com Helped-by: Eric Sunshine sunsh...@sunshineco.com --- git.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git.c b/git.c index 1780233..96723b8 100644 --- a/git.c +++ b/git.c @@ -619,6 +619,7 @@ int main(int argc, char **av) { const char **argv = (const char **) av; const char *cmd; + int done_help, was_alias; startup_info = git_startup_info; @@ -681,8 +682,6 @@ int main(int argc, char **av) setup_path(); while (1) { - static int done_help = 0; - static int was_alias = 0; was_alias = run_argv(argc, argv); if (errno != ENOENT) break; -- 2.3.1.422.ge618558 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] hash-object: add -v/--verbose option
This patch provides ability to pass -v/--verbose option to the git hash-object command. hash-object will print not only hash, but also file path of a file from what hash was calculated. It can be useful in scripting, especially with --stdin-paths option. For example: $ git hash-object -v test e69de29bb2d1d6434b8b29ae775ad8c2e48c5391test Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/hash-object.c | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/builtin/hash-object.c b/builtin/hash-object.c index 207b90c..97961ee 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -10,6 +10,8 @@ #include parse-options.h #include exec_cmd.h +static int verbose; + /* * This is to create corrupt objects for debugging and as such it * needs to bypass the data conversion performed by, and the type @@ -43,7 +45,10 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags, die((flags HASH_WRITE_OBJECT) ? Unable to add %s to database : Unable to hash %s, path); - printf(%s\n, sha1_to_hex(sha1)); + if (verbose) + printf(%s\t%s\n, sha1_to_hex(sha1), path); + else + printf(%s\n, sha1_to_hex(sha1)); maybe_flush_or_die(stdout, hash to stdout); } @@ -79,7 +84,7 @@ static void hash_stdin_paths(const char *type, int no_filters, unsigned flags, int cmd_hash_object(int argc, const char **argv, const char *prefix) { static const char * const hash_object_usage[] = { - N_(git hash-object [-t type] [-w] [--path=file | --no-filters] [--stdin] [--] file...), + N_(git hash-object [-t type] [-w] [-v] [--path=file | --no-filters] [--stdin] [--] file...), N_(git hash-object --stdin-paths list-of-paths), NULL }; @@ -99,6 +104,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix) OPT_BOOL( 0 , no-filters, no_filters, N_(store file as is without filters)), OPT_BOOL( 0, literally, literally, N_(just hash any random garbage to create corrupt objects for debugging Git)), OPT_STRING( 0 , path, vpath, N_(file), N_(process file as it were from this path)), + OPT__VERBOSE(verbose, N_(show hash and file path)), OPT_END() }; int i; @@ -108,6 +114,11 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, NULL, hash_object_options, hash_object_usage, 0); + if (verbose literally) + errstr = Can't use --verbose with --literally; + else if (verbose hashstdin) + errstr = Can't use --verbose with --stdin; + if (flags HASH_WRITE_OBJECT) { prefix = setup_git_directory(); prefix_length = prefix ? strlen(prefix) : 0; -- 2.3.1.167.g7f4ba4b.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] t1007-hash-object: add tests for verbose hash-object
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- t/t1007-hash-object.sh | 11 +++ 1 file changed, 11 insertions(+) diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh index f83df8e..fa957bf 100755 --- a/t/t1007-hash-object.sh +++ b/t/t1007-hash-object.sh @@ -201,4 +201,15 @@ test_expect_success 'corrupt tag' ' test_must_fail git hash-object -t tag --stdin /dev/null ' +filename=hello +hello_sha1_verbose=$hello_sha1\t$filename + +test_expect_success 'hash-object verbose' ' + test $(echo $hello_sha1_verbose) = $(git hash-object -v $filename) +' + +test_expect_success Can't use --verbose and --stdin together ' + echo example | test_must_fail git hash-object --verbose --stdin +' + test_done -- 2.3.1.167.g7f4ba4b.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git: make was_alias non-static
'was_alias' variable does not need to store it's value each iteration in the loop, anyway this variable changes it's value with run_argv. So it does not need to be static. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- git.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.c b/git.c index 1780233..b8b6520 100644 --- a/git.c +++ b/git.c @@ -682,7 +682,7 @@ int main(int argc, char **av) while (1) { static int done_help = 0; - static int was_alias = 0; + int was_alias = 0; was_alias = run_argv(argc, argv); if (errno != ENOENT) break; -- 2.3.1.422.ge618558.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Git.pm: two minor typo fixes
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- perl/Git.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/perl/Git.pm b/perl/Git.pm index b5905ee..9026a7b 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -695,7 +695,7 @@ Retrieve the integer configuration CVARIABLE. The return value is simple decimal number. An optional value suffix of 'k', 'm', or 'g' in the config file will cause the value to be multiplied by 1024, 1048576 (1024^2), or 1073741824 (1024^3) prior to output. -It would return Cundef if configuration variable is not defined, +It would return Cundef if configuration variable is not defined. =cut @@ -704,7 +704,7 @@ sub config_int { } # Common subroutine to implement bulk of what the config* family of methods -# do. This curently wraps command('config') so it is not so fast. +# do. This currently wraps command('config') so it is not so fast. sub _config_common { my ($opts) = shift @_; my ($self, $var) = _maybe_self(@_); -- 2.3.0.80.g18d0fec -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] INSTALL: minor typo fix
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- INSTALL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index ffb071e..6f1c3d5 100644 --- a/INSTALL +++ b/INSTALL @@ -53,7 +53,7 @@ or As a caveat: a profile-optimized build takes a *lot* longer since the git tree must be built twice, and in order for the profiling -measurements to work properly, ccache must be disabled and the test +measurements to work properly, cache must be disabled and the test suite has to be run using only a single CPU. In addition, the profile feedback build stage currently generates a lot of additional compiler warnings. -- 2.3.0-rc1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Documentation/git-add.txt: add `add.ginore-errors` configuration variable
'git add' supports not only `add.ignoreErrors`, but also `add.ignore-errors` configuration variable. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-add.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index 1c74907..f68c2a2 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -155,8 +155,8 @@ for git add --no-all pathspec..., i.e. ignored removed files. If some files could not be added because of errors indexing them, do not abort the operation, but continue adding the others. The command shall still exit with non-zero status. - The configuration variable `add.ignoreErrors` can be set to - true to make this the default behaviour. + The configuration variable `add.ignoreErrors` or `add.ignore-errors` + can be set to true to make this the default behaviour. --ignore-missing:: This option can only be used together with --dry-run. By using -- 2.3.0.rc1.275.g028c360 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/7] Coding style fixes.
I made separate patch for every file. Please, let me know if need to squash it into one commit. 2015-01-23 17:06 GMT+06:00 Alexander Kuleshov kuleshovm...@gmail.com: This patch set contatins minor style fixes. CodingGuidelines contains rule that the star must side with variable name. Alexander Kuleshov (7): show-branch: minor style fix clone: minor style fix test-hashmap: minor style fix http-backend: minor style fix refs: minor style fix quote: minor style fix fast-import: minor style fix builtin/clone.c | 2 +- builtin/show-branch.c | 2 +- fast-import.c | 2 +- http-backend.c| 2 +- quote.c | 2 +- refs.h| 2 +- test-hashmap.c| 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) -- 2.3.0.rc1.275.g028c360 -- _ 0xAX -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/7] Coding style fixes.
This patch set contatins minor style fixes. CodingGuidelines contains rule that the star must side with variable name. Alexander Kuleshov (7): show-branch: minor style fix clone: minor style fix test-hashmap: minor style fix http-backend: minor style fix refs: minor style fix quote: minor style fix fast-import: minor style fix builtin/clone.c | 2 +- builtin/show-branch.c | 2 +- fast-import.c | 2 +- http-backend.c| 2 +- quote.c | 2 +- refs.h| 2 +- test-hashmap.c| 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) -- 2.3.0.rc1.275.g028c360 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/7] test-hashmap: minor style fix
Asterisk must be next with variable Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- test-hashmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-hashmap.c b/test-hashmap.c index cc2891d..5f67120 100644 --- a/test-hashmap.c +++ b/test-hashmap.c @@ -14,13 +14,13 @@ static const char *get_value(const struct test_entry *e) } static int test_entry_cmp(const struct test_entry *e1, - const struct test_entry *e2, const char* key) + const struct test_entry *e2, const char *key) { return strcmp(e1-key, key ? key : e2-key); } static int test_entry_cmp_icase(const struct test_entry *e1, - const struct test_entry *e2, const char* key) + const struct test_entry *e2, const char *key) { return strcasecmp(e1-key, key ? key : e2-key); } -- 2.3.0.rc1.275.g028c360 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/7] http-backend: minor style fix
Asterisk must be next with variable Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- http-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-backend.c b/http-backend.c index b6c0484..7b5670b 100644 --- a/http-backend.c +++ b/http-backend.c @@ -515,7 +515,7 @@ static NORETURN void die_webcgi(const char *err, va_list params) exit(0); /* we successfully reported a failure ;-) */ } -static char* getdir(void) +static char *getdir(void) { struct strbuf buf = STRBUF_INIT; char *pathinfo = getenv(PATH_INFO); -- 2.3.0.rc1.275.g028c360 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/7] clone: minor style fix
Asterisk must be next with variable Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/clone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/clone.c b/builtin/clone.c index d262a4d..a1ca780 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -741,7 +741,7 @@ static void write_refspec_config(const char *src_ref_prefix, static void dissociate_from_references(void) { - static const char* argv[] = { repack, -a, -d, NULL }; + static const char *argv[] = { repack, -a, -d, NULL }; if (run_command_v_opt(argv, RUN_GIT_CMD|RUN_COMMAND_NO_STDIN)) die(_(cannot repack to clean up)); -- 2.3.0.rc1.275.g028c360 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/7] refs: minor style fix
Asterisk must be next with variable Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- refs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refs.h b/refs.h index 425ecf7..bd8afe2 100644 --- a/refs.h +++ b/refs.h @@ -86,7 +86,7 @@ extern int for_each_branch_ref(each_ref_fn, void *); extern int for_each_remote_ref(each_ref_fn, void *); extern int for_each_replace_ref(each_ref_fn, void *); extern int for_each_glob_ref(each_ref_fn, const char *pattern, void *); -extern int for_each_glob_ref_in(each_ref_fn, const char *pattern, const char* prefix, void *); +extern int for_each_glob_ref_in(each_ref_fn, const char *pattern, const char *prefix, void *); extern int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data); extern int for_each_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data); -- 2.3.0.rc1.275.g028c360 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 7/7] fast-import: minor style fix
Asterisk must be next with variable Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- fast-import.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fast-import.c b/fast-import.c index 1b50923..fec67ca 100644 --- a/fast-import.c +++ b/fast-import.c @@ -3110,7 +3110,7 @@ static void parse_progress(void) skip_optional_lf(); } -static char* make_fast_import_path(const char *path) +static char *make_fast_import_path(const char *path) { if (!relative_marks_paths || is_absolute_path(path)) return xstrdup(path); -- 2.3.0.rc1.275.g028c360 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/7] quote: minor style fix
Asterisk must be next with variable Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- quote.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quote.c b/quote.c index 7920e18..02e9a3c 100644 --- a/quote.c +++ b/quote.c @@ -42,7 +42,7 @@ void sq_quote_buf(struct strbuf *dst, const char *src) free(to_free); } -void sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen) +void sq_quote_argv(struct strbuf *dst, const char **argv, size_t maxlen) { int i; -- 2.3.0.rc1.275.g028c360 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/7] show-branch: minor style fix
Asterisk must be next with variable Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/show-branch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 3a7ec55..e7684c8 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -6,7 +6,7 @@ #include parse-options.h #include commit-slab.h -static const char* show_branch_usage[] = { +static const char *show_branch_usage[] = { N_(git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]\n [--current] [--color[=when] | --no-color] [--sparse]\n [--more=n | --list | --independent | --merge-base]\n -- 2.3.0.rc1.275.g028c360 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Makefile: do not compile git with debugging symbols by default
Standard user has no need in debugging information. This patch adds DEBUG=1 option to compile git with debugging symbols and compile without it by default. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Makefile | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b5b4cee..83ff691 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ all:: # Define V=1 to have a more verbose compile. # +# Define DEBUG=1 to compile git with debugging symbols. +# # Define SHELL_PATH to a POSIX shell if your /bin/sh is broken. # # Define SANE_TOOL_PATH to a colon-separated list of paths to prepend @@ -363,8 +365,13 @@ GIT-VERSION-FILE: FORCE -include GIT-VERSION-FILE # CFLAGS and LDFLAGS are for the users to override from the command line. +DEBUG_CFLAGS= + +ifdef DEBUG + DEBUG_CFLAGS = -g +endif -CFLAGS = -g -O2 -Wall +CFLAGS = $(DEBUG_CFLAGS) -O2 -Wall LDFLAGS = ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS) -- 2.3.0.rc1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] parse-opts: add OPT_SUBCMD()
OPT_SUBCMD can be used for parsing git commands which has not only short/long options, but subcomands. For example: git bundle (create, verify and etc...) or git remote (add, rename and etc...) Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- parse-options.c | 25 + parse-options.h | 8 t/t0040-parse-options.sh | 13 + test-parse-options.c | 3 +++ 4 files changed, 49 insertions(+) diff --git a/parse-options.c b/parse-options.c index 80106c0..79f971e 100644 --- a/parse-options.c +++ b/parse-options.c @@ -121,6 +121,10 @@ static int get_value(struct parse_opt_ctx_t *p, *(int *)opt-value = unset ? 0 : opt-defval; return 0; + case OPTION_SUBCMD: + *(int *)opt-value = 1; + return 0; + case OPTION_CMDMODE: /* * Giving the same mode option twice, although is unnecessary, @@ -314,6 +318,17 @@ is_abbreviated: return -2; } +static int parse_subcmd_opt(struct parse_opt_ctx_t *p, const char *arg, +const struct option *options) { + const struct option *all_opts = options; + for (; options-type != OPTION_END; options++) { + if (options-long_name !strcmp(options-long_name, arg)) + return get_value(p, options, all_opts, 0); + } + + return -2; +} + static int parse_nodash_opt(struct parse_opt_ctx_t *p, const char *arg, const struct option *options) { @@ -417,6 +432,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx, const struct option *options, const char * const usagestr[]) { + int argc = ctx-argc; int internal_help = !(ctx-flags PARSE_OPT_NO_INTERNAL_HELP); /* we must reset -opt, unknown short option leave it dangling */ @@ -426,6 +442,11 @@ int parse_options_step(struct parse_opt_ctx_t *ctx, const char *arg = ctx-argv[0]; if (*arg != '-' || !arg[1]) { + if (ctx-argc == argc + options-type == OPTION_SUBCMD + parse_subcmd_opt(ctx, arg, options) == 0){ + continue; + } if (parse_nodash_opt(ctx, arg, options) == 0) continue; if (ctx-flags PARSE_OPT_STOP_AT_NON_OPTION) @@ -581,6 +602,10 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx, size_t pos; int pad; + if (opts-type == OPTION_SUBCMD) { + continue; + } + if (opts-type == OPTION_GROUP) { fputc('\n', outfile); if (*opts-help) diff --git a/parse-options.h b/parse-options.h index 7940bc7..0e75a85 100644 --- a/parse-options.h +++ b/parse-options.h @@ -13,6 +13,8 @@ enum parse_opt_type { OPTION_COUNTUP, OPTION_SET_INT, OPTION_CMDMODE, + OPTION_SUBCMD, + /* options with arguments (usually) */ OPTION_STRING, OPTION_INTEGER, @@ -115,6 +117,10 @@ struct option { #define OPT_END() { OPTION_END } #define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, \ (h), PARSE_OPT_NOARG} + +#define OPT_SUBCMD(l, v, h) { OPTION_SUBCMD, 0, (l), (v), NULL, \ + (h), PARSE_OPT_NOARG} + #define OPT_GROUP(h){ OPTION_GROUP, 0, NULL, NULL, NULL, (h) } #define OPT_BIT(s, l, v, h, b) { OPTION_BIT, (s), (l), (v), NULL, (h), \ PARSE_OPT_NOARG, NULL, (b) } @@ -125,8 +131,10 @@ struct option { #define OPT_SET_INT(s, l, v, h, i) { OPTION_SET_INT, (s), (l), (v), NULL, \ (h), PARSE_OPT_NOARG, NULL, (i) } #define OPT_BOOL(s, l, v, h)OPT_SET_INT(s, l, v, h, 1) + #define OPT_HIDDEN_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \ (h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1} + #define OPT_CMDMODE(s, l, v, h, i) { OPTION_CMDMODE, (s), (l), (v), NULL, \ (h), PARSE_OPT_NOARG|PARSE_OPT_NONEG, NULL, (i) } #define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), N_(n), (h) } diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index a90c86b..7898a5a 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -65,6 +65,7 @@ verbose: 0 quiet: no dry run: no file: (not set) +subcommand: 1 EOF check() { @@ -142,6 +143,7 @@ verbose: 2 quiet: no dry run: yes file: prefix/my.file +subcommand: 1 EOF test_expect_success 'short options' ' @@ -161,6 +163,7 @@ verbose: 2 quiet: no dry run: no file: prefix/fi.le
[PATCH] git-add--interactive: return from list_and_choose if there is zero candidates
This patch introduce the check in list_and_choose() routine for the list. If list is empty just return. It can be useful for example if user selects 'add untracked' and there are no untracked files, Add untracked opens. But it does not make sense in this case, because there are no untracked files. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- git-add--interactive.perl | 5 + 1 file changed, 5 insertions(+) diff --git a/git-add--interactive.perl b/git-add--interactive.perl index 94b988c..85b2fe7 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -519,6 +519,9 @@ sub error_msg { sub list_and_choose { my ($opts, @stuff) = @_; my (@chosen, @return); + if (!@stuff) { + return @return; + } my $i; my @prefixes = find_unique_prefixes(@stuff) unless $opts-{LIST_ONLY}; @@ -729,6 +732,8 @@ sub add_untracked_cmd { if (@add) { system(qw(git update-index --add --), @add); say_n_paths('added', @add); + } else { + print No untracked files.\n; } print \n; } -- 2.3.0.rc1.247.gb53aa6f.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Makefile: do not compile git with debugging symbols by default
Hello Jeff, Yes, main point is size of executable. I'm sorry, didn't see 'strip' target. What if we will strip git and other executable files by default and add -g option and don't strip it if DEBUG=1 passed to make. Something like this: git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) git.o \ $(BUILTIN_OBJS) $(LIBS) ifneq ($(DEBUG),1) $(MAKE) strip endif Thank you. 2015-01-22 19:00 GMT+06:00 Jeff King p...@peff.net: On Thu, Jan 22, 2015 at 06:50:37PM +0600, Alexander Kuleshov wrote: Standard user has no need in debugging information. This patch adds DEBUG=1 option to compile git with debugging symbols and compile without it by default. This explanation is missing why it is beneficial _not_ to have the debugging information. I expect the answer is it makes the executable smaller. And that is true, but it gets smaller still if you run strip on the result: $ make CFLAGS= /dev/null 21 wc -c git 2424248 $ make CFLAGS=-g /dev/null 21 wc -c git 4500816 $ strip git wc -c git 2109200 So I am not sure who this is helping. If you are size-conscious, you should use strip, in which case the -g flag does not matter (and we even have make strip to help you). Is there some other reason to avoid the debugging information? -Peff -- _ 0xAX -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Makefile: do not compile git with debugging symbols by default
Or even still -g as it now, because anyway debugging info will be removed with stripping 2015-01-22 22:51 GMT+06:00 Alexander Kuleshov kuleshovm...@gmail.com: Hello Jeff, Yes, main point is size of executable. I'm sorry, didn't see 'strip' target. What if we will strip git and other executable files by default and add -g option and don't strip it if DEBUG=1 passed to make. Something like this: git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) git.o \ $(BUILTIN_OBJS) $(LIBS) ifneq ($(DEBUG),1) $(MAKE) strip endif Thank you. 2015-01-22 19:00 GMT+06:00 Jeff King p...@peff.net: On Thu, Jan 22, 2015 at 06:50:37PM +0600, Alexander Kuleshov wrote: Standard user has no need in debugging information. This patch adds DEBUG=1 option to compile git with debugging symbols and compile without it by default. This explanation is missing why it is beneficial _not_ to have the debugging information. I expect the answer is it makes the executable smaller. And that is true, but it gets smaller still if you run strip on the result: $ make CFLAGS= /dev/null 21 wc -c git 2424248 $ make CFLAGS=-g /dev/null 21 wc -c git 4500816 $ strip git wc -c git 2109200 So I am not sure who this is helping. If you are size-conscious, you should use strip, in which case the -g flag does not matter (and we even have make strip to help you). Is there some other reason to avoid the debugging information? -Peff -- _ 0xAX -- _ 0xAX -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] i18n: bundle: mark git-bundle usage for translation
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/bundle.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/bundle.c b/builtin/bundle.c index 92a8a60..ca4a6a4 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -10,10 +10,10 @@ */ static const char builtin_bundle_usage[] = - git bundle create file git-rev-list args\n - or: git bundle verify file\n - or: git bundle list-heads file [refname...]\n - or: git bundle unbundle file [refname...]; + N_(git bundle create file git-rev-list args\n + or: git bundle verify file\n + or: git bundle list-heads file [refname...]\n + or: git bundle unbundle file [refname...]); int cmd_bundle(int argc, const char **argv, const char *prefix) { -- 2.3.0.rc1.246.g8d68d51.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git-add--interactive: print message if there are no untracked files
If user selects 'add untracked' and there are no untracked files, Add untracked opens. But it does not make sense in this case, because there are no untracked files. So let's print message and exit from add untracked mode. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- git-add--interactive.perl | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/git-add--interactive.perl b/git-add--interactive.perl index 94b988c..1a6dcf3 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -724,11 +724,15 @@ sub revert_cmd { } sub add_untracked_cmd { - my @add = list_and_choose({ PROMPT = 'Add untracked' }, - list_untracked()); - if (@add) { - system(qw(git update-index --add --), @add); - say_n_paths('added', @add); + if (system(qw(git ls-files --others --exclude-standard --))) { + my @add = list_and_choose({ PROMPT = 'Add untracked' }, + list_untracked()); + if (@add) { + system(qw(git update-index --add --), @add); + say_n_paths('added', @add); + } + } else { + print No untracked files.\n; } print \n; } -- 2.3.0.rc1.247.gb53aa6f -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] i18n: bundle: mark git-bundle usage for translation
Ok, understand. How to be with it? Resend after 2.3? Thank you. 2015-01-22 3:13 GMT+06:00 Junio C Hamano gits...@pobox.com: Thanks, but please hold this off until the 2.3 final is tagged. It is way too late for anything that is not a regression fix at this point in this cycle, and changes that affect i18n are the last thing we want to take late in the cycle because l10n people need time to update the translations. -- _ 0xAX -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] git-add--interactive: print message if there are no untracked files
No i don't see any reasons why list_and_choose() shoud give a prompt without candidates. Will resed patch. Thank you. 2015-01-22 3:17 GMT+06:00 Junio C Hamano gits...@pobox.com: Junio C Hamano gits...@pobox.com writes: sub add_untracked_cmd { -my @add = list_and_choose({ PROMPT = 'Add untracked' }, - list_untracked()); -if (@add) { -system(qw(git update-index --add --), @add); -say_n_paths('added', @add); +if (system(qw(git ls-files --others --exclude-standard --))) { But this ls-files invocation that knows too much about how list_untracked() computes things does not. Why not ... or something instead? Actually, is there any case where list_and_choose() should give a prompt to choose from zero candidates? In other words, I am wondering if this affects other callers of list_and_choose in any negative way. git-add--interactive.perl | 4 1 file changed, 4 insertions(+) diff --git a/git-add--interactive.perl b/git-add--interactive.perl index 94b988c..46ed9a7 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -519,6 +519,10 @@ sub error_msg { sub list_and_choose { my ($opts, @stuff) = @_; my (@chosen, @return); + + if (!@stuff) { + return @return; + } my $i; my @prefixes = find_unique_prefixes(@stuff) unless $opts-{LIST_ONLY}; -- _ 0xAX -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] pack-bitmap: fix typo
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- pack-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 0cd85f6..365f9d9 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -60,7 +60,7 @@ static struct bitmap_index { struct ewah_bitmap *blobs; struct ewah_bitmap *tags; - /* Map from SHA1 - `stored_bitmap` for all the bitmapped comits */ + /* Map from SHA1 - `stored_bitmap` for all the bitmapped commits */ khash_sha1 *bitmaps; /* Number of bitmapped commits */ -- 2.3.0-rc1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] t/lib-terminal.sh: fix typo
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- t/lib-terminal.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/lib-terminal.sh b/t/lib-terminal.sh index 5184549..cd220e3 100644 --- a/t/lib-terminal.sh +++ b/t/lib-terminal.sh @@ -1,7 +1,7 @@ # Helpers for terminal output tests. # Catch tests which should depend on TTY but forgot to. There's no need -# to aditionally check that the TTY prereq is set here. If the test declared +# to additionally check that the TTY prereq is set here. If the test declared # it and we are running the test, then it must have been set. test_terminal () { if ! test_declared_prereq TTY -- 2.3.0-rc1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] Makefile: collect some Makefile variables instead of directly assignment
Hello Junio, 2015-01-21 15:23 GMT+06:00 Junio C Hamano gits...@pobox.com: Alexander Kuleshov kuleshovm...@gmail.com writes: Some of Makefile variables as TEST_PROGRAMS_NEED_X and BUILTIN_OBJS filled directly by hand, let's collect it with the standard functions of 'make' util. I am not sure if we want to do this. $(wildcard) is a double-edged sword. It will grab any file that matches on the filesystem, not just the ones we want to include in the Git source set. I often have a file called test-something and I'd prefer not to see such a random thing included in the build, only because the filename matches some pattern. Yes, grabbing files by test-*.c is unreliable in this case. But what about builtin/*.c? Is there any plans that builtin will contain something another than builtin object files? While we consider anything with a name that match the pattern we say matter (e.g. test-*.c or builtin/*.c) as part of the source set is sometimes handy (it allows us to be lazy), it risks surprising unsuspecting users. So I dunno. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] Makefile: collect some Makefile variables instead of directly assignment
Some of Makefile variables as TEST_PROGRAMS_NEED_X and BUILTIN_OBJS filled directly by hand, let's collect it with the standard functions of 'make' util. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Makefile | 134 +-- 1 file changed, 2 insertions(+), 132 deletions(-) diff --git a/Makefile b/Makefile index b5b4cee..055db4b 100644 --- a/Makefile +++ b/Makefile @@ -563,38 +563,7 @@ X = PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS)) -TEST_PROGRAMS_NEED_X += test-chmtime -TEST_PROGRAMS_NEED_X += test-ctype -TEST_PROGRAMS_NEED_X += test-config -TEST_PROGRAMS_NEED_X += test-date -TEST_PROGRAMS_NEED_X += test-delta -TEST_PROGRAMS_NEED_X += test-dump-cache-tree -TEST_PROGRAMS_NEED_X += test-dump-split-index -TEST_PROGRAMS_NEED_X += test-dump-untracked-cache -TEST_PROGRAMS_NEED_X += test-genrandom -TEST_PROGRAMS_NEED_X += test-hashmap -TEST_PROGRAMS_NEED_X += test-index-version -TEST_PROGRAMS_NEED_X += test-line-buffer -TEST_PROGRAMS_NEED_X += test-match-trees -TEST_PROGRAMS_NEED_X += test-mergesort -TEST_PROGRAMS_NEED_X += test-mktemp -TEST_PROGRAMS_NEED_X += test-parse-options -TEST_PROGRAMS_NEED_X += test-path-utils -TEST_PROGRAMS_NEED_X += test-prio-queue -TEST_PROGRAMS_NEED_X += test-read-cache -TEST_PROGRAMS_NEED_X += test-regex -TEST_PROGRAMS_NEED_X += test-revision-walking -TEST_PROGRAMS_NEED_X += test-run-command -TEST_PROGRAMS_NEED_X += test-scrap-cache-tree -TEST_PROGRAMS_NEED_X += test-sha1 -TEST_PROGRAMS_NEED_X += test-sha1-array -TEST_PROGRAMS_NEED_X += test-sigchain -TEST_PROGRAMS_NEED_X += test-string-list -TEST_PROGRAMS_NEED_X += test-submodule-config -TEST_PROGRAMS_NEED_X += test-subprocess -TEST_PROGRAMS_NEED_X += test-svn-fe -TEST_PROGRAMS_NEED_X += test-urlmatch-normalization -TEST_PROGRAMS_NEED_X += test-wildmatch +TEST_PROGRAMS_NEED_X = $(patsubst %.c,%, $(wildcard test-*.c)) TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X)) @@ -811,105 +780,7 @@ LIB_OBJS += wt-status.o LIB_OBJS += xdiff-interface.o LIB_OBJS += zlib.o -BUILTIN_OBJS += builtin/add.o -BUILTIN_OBJS += builtin/annotate.o -BUILTIN_OBJS += builtin/apply.o -BUILTIN_OBJS += builtin/archive.o -BUILTIN_OBJS += builtin/bisect--helper.o -BUILTIN_OBJS += builtin/blame.o -BUILTIN_OBJS += builtin/branch.o -BUILTIN_OBJS += builtin/bundle.o -BUILTIN_OBJS += builtin/cat-file.o -BUILTIN_OBJS += builtin/check-attr.o -BUILTIN_OBJS += builtin/check-ignore.o -BUILTIN_OBJS += builtin/check-mailmap.o -BUILTIN_OBJS += builtin/check-ref-format.o -BUILTIN_OBJS += builtin/checkout-index.o -BUILTIN_OBJS += builtin/checkout.o -BUILTIN_OBJS += builtin/clean.o -BUILTIN_OBJS += builtin/clone.o -BUILTIN_OBJS += builtin/column.o -BUILTIN_OBJS += builtin/commit-tree.o -BUILTIN_OBJS += builtin/commit.o -BUILTIN_OBJS += builtin/config.o -BUILTIN_OBJS += builtin/count-objects.o -BUILTIN_OBJS += builtin/credential.o -BUILTIN_OBJS += builtin/describe.o -BUILTIN_OBJS += builtin/diff-files.o -BUILTIN_OBJS += builtin/diff-index.o -BUILTIN_OBJS += builtin/diff-tree.o -BUILTIN_OBJS += builtin/diff.o -BUILTIN_OBJS += builtin/fast-export.o -BUILTIN_OBJS += builtin/fetch-pack.o -BUILTIN_OBJS += builtin/fetch.o -BUILTIN_OBJS += builtin/fmt-merge-msg.o -BUILTIN_OBJS += builtin/for-each-ref.o -BUILTIN_OBJS += builtin/fsck.o -BUILTIN_OBJS += builtin/gc.o -BUILTIN_OBJS += builtin/get-tar-commit-id.o -BUILTIN_OBJS += builtin/grep.o -BUILTIN_OBJS += builtin/hash-object.o -BUILTIN_OBJS += builtin/help.o -BUILTIN_OBJS += builtin/index-pack.o -BUILTIN_OBJS += builtin/init-db.o -BUILTIN_OBJS += builtin/interpret-trailers.o -BUILTIN_OBJS += builtin/log.o -BUILTIN_OBJS += builtin/ls-files.o -BUILTIN_OBJS += builtin/ls-remote.o -BUILTIN_OBJS += builtin/ls-tree.o -BUILTIN_OBJS += builtin/mailinfo.o -BUILTIN_OBJS += builtin/mailsplit.o -BUILTIN_OBJS += builtin/merge.o -BUILTIN_OBJS += builtin/merge-base.o -BUILTIN_OBJS += builtin/merge-file.o -BUILTIN_OBJS += builtin/merge-index.o -BUILTIN_OBJS += builtin/merge-ours.o -BUILTIN_OBJS += builtin/merge-recursive.o -BUILTIN_OBJS += builtin/merge-tree.o -BUILTIN_OBJS += builtin/mktag.o -BUILTIN_OBJS += builtin/mktree.o -BUILTIN_OBJS += builtin/mv.o -BUILTIN_OBJS += builtin/name-rev.o -BUILTIN_OBJS += builtin/notes.o -BUILTIN_OBJS += builtin/pack-objects.o -BUILTIN_OBJS += builtin/pack-redundant.o -BUILTIN_OBJS += builtin/pack-refs.o -BUILTIN_OBJS += builtin/patch-id.o -BUILTIN_OBJS += builtin/prune-packed.o -BUILTIN_OBJS += builtin/prune.o -BUILTIN_OBJS += builtin/push.o -BUILTIN_OBJS += builtin/read-tree.o -BUILTIN_OBJS += builtin/receive-pack.o -BUILTIN_OBJS += builtin/reflog.o -BUILTIN_OBJS += builtin/remote.o -BUILTIN_OBJS += builtin/remote-ext.o -BUILTIN_OBJS += builtin/remote-fd.o -BUILTIN_OBJS += builtin/repack.o -BUILTIN_OBJS += builtin/replace.o -BUILTIN_OBJS += builtin/rerere.o -BUILTIN_OBJS += builtin/reset.o -BUILTIN_OBJS += builtin/rev-list.o -BUILTIN_OBJS += builtin/rev-parse.o -BUILTIN_OBJS += builtin/revert.o -BUILTIN_OBJS
[PATCH 0/2] Fix typos in various places
These patches provides two minor typo fixes in pack-bitmap.c and t/lib-terminal.sh Alexander Kuleshov (2): pack-bitmap: fix typo t/lib-terminal.sh: fix typo pack-bitmap.c | 2 +- t/lib-terminal.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.3.0-rc1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2] Fix typos in various places
These patches provides two minor typo fixes in pack-bitmap.c and t/lib-terminal.sh Alexander Kuleshov (2): pack-bitmap: fix typo t/lib-terminal.sh: fix typo pack-bitmap.c | 2 +- t/lib-terminal.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.3.0-rc1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] move MAXDEPTH definition to the cache.h
There are a couple of source code files as abspath.c, lockfile.c and etc..., which defines MAXDEPTH macro. All of these definitions are the same, so let's move MAXDEPTH definition to the cache.h instead of directly declaration of this macro in all these files. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- abspath.c | 3 --- cache.h | 1 + http-push.c | 3 --- lockfile.c | 4 refs.c | 2 -- 5 files changed, 1 insertion(+), 12 deletions(-) diff --git a/abspath.c b/abspath.c index 5edb4e7..9209522 100644 --- a/abspath.c +++ b/abspath.c @@ -11,9 +11,6 @@ int is_directory(const char *path) return (!stat(path, st) S_ISDIR(st.st_mode)); } -/* We allow recursive symbolic links. Only within reason, though. */ -#define MAXDEPTH 5 - /* * Return the real path (i.e., absolute path, with symlinks resolved * and extra slashes removed) equivalent to the specified path. (If diff --git a/cache.h b/cache.h index 64aa287..cac85b7 100644 --- a/cache.h +++ b/cache.h @@ -1010,6 +1010,7 @@ extern int read_ref(const char *refname, unsigned char *sha1); * Caps and underscores refers to the special refs, such as HEAD, * FETCH_HEAD and friends, that all live outside of the refs/ directory. */ +#define MAXDEPTH 5 #define RESOLVE_REF_READING 0x01 #define RESOLVE_REF_NO_RECURSE 0x02 #define RESOLVE_REF_ALLOW_BAD_NAME 0x04 diff --git a/http-push.c b/http-push.c index 0beb7ab..bb1f82e 100644 --- a/http-push.c +++ b/http-push.c @@ -70,9 +70,6 @@ enum XML_Status { #define FETCHING (1u18) #define PUSHING (1u19) -/* We allow recursive symbolic refs. Only within reason, though */ -#define MAXDEPTH 5 - static int pushing; static int aborted; static signed char remote_dir_exists[256]; diff --git a/lockfile.c b/lockfile.c index 9889277..88d0102 100644 --- a/lockfile.c +++ b/lockfile.c @@ -59,10 +59,6 @@ static void trim_last_path_component(struct strbuf *path) strbuf_setlen(path, i); } - -/* We allow recursive symbolic links. Only within reason, though */ -#define MAXDEPTH 5 - /* * path contains a path that might be a symlink. * diff --git a/refs.c b/refs.c index 872cb26..c37879f 100644 --- a/refs.c +++ b/refs.c @@ -1335,8 +1335,6 @@ static struct ref_dir *get_loose_refs(struct ref_cache *refs) return get_ref_dir(refs-loose); } -/* We allow recursive symbolic refs. Only within reason, though */ -#define MAXDEPTH 5 #define MAXREFLEN (1024) /* -- 2.3.0.rc0.286.ga3dc223.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] hash-object: add -t and --no-filters options to the hash-object synopsis
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/hash-object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/hash-object.c b/builtin/hash-object.c index 207b90c..a8100a7 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -80,7 +80,7 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix) { static const char * const hash_object_usage[] = { N_(git hash-object [-t type] [-w] [--path=file | --no-filters] [--stdin] [--] file...), - N_(git hash-object --stdin-paths list-of-paths), + N_(git hash-object [-t type] [-w] --stdin-paths [--no-filters] list-of-paths), NULL }; const char *type = blob_type; -- 2.3.0.rc0.286.ga3dc223.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] Documentation/git-branch.txt: add long options to git branch synopsis
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-branch.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 311b336..722f865 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -8,7 +8,7 @@ git-branch - List, create, or delete branches SYNOPSIS [verse] -'git branch' [--color[=when] | --no-color] [-r | -a] +'git branch' [--color[=when] | --no-color] [(-r|--remotes) | (-a|--all)] [--list] [-v [--abbrev=length | --no-abbrev]] [--column[=options] | --no-column] [(--merged | --no-merged | --contains) [commit]] [pattern...] -- 2.3.0.rc0.286.ga3dc223.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] branch: add support for --dry-run option
This patch adds support -n/--dry-run option for branch(es) deletion. If -n/--dry-run option passed to git branch -d branch..., branch(es) will not be removed, instead just print list of branches that are to be removed. For example: $ git branch a b c * master $ git branch -d -n a b c delete branch 'a' (261c0d1) delete branch 'b' (261c0d1) delete branch 'c' (261c0d1) Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-branch.txt | 11 +-- builtin/branch.c | 13 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 311b336..32ea581 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -16,7 +16,7 @@ SYNOPSIS 'git branch' (--set-upstream-to=upstream | -u upstream) [branchname] 'git branch' --unset-upstream [branchname] 'git branch' (-m | -M) [oldbranch] newbranch -'git branch' (-d | -D) [-r] branchname... +'git branch' (-d | -D) [--dry-run | -n] [-r] branchname... 'git branch' --edit-description [branchname] DESCRIPTION @@ -63,7 +63,9 @@ to happen. With a `-d` or `-D` option, `branchname` will be deleted. You may specify more than one branch for deletion. If the branch currently -has a reflog then the reflog will also be deleted. +has a reflog then the reflog will also be deleted. If passed `-n` or +`--dry-run` option, branch(es) will be not removed, but show a list of +branches that are to be removed. Use `-r` together with `-d` to delete remote-tracking branches. Note, that it only makes sense to delete remote-tracking branches if they no longer exist @@ -83,6 +85,11 @@ OPTIONS -D:: Delete a branch irrespective of its merged status. +-n:: +--dry-run:: + Don't remove the branch(es), but show a list of branches that are + to be removed. + -l:: --create-reflog:: Create the branch's reflog. This activates recording of diff --git a/builtin/branch.c b/builtin/branch.c index d8949cb..4a35a2f 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -61,6 +61,7 @@ static unsigned char merge_filter_ref[20]; static struct string_list output = STRING_LIST_INIT_DUP; static unsigned int colopts; +static int branch_delete_show_only; static int parse_branch_color_slot(const char *slot) { @@ -255,6 +256,17 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, continue; } + if (branch_delete_show_only) { + printf(remote_branch + ? _(delete remote branch '%s' (%s)\n) + : _(delete branch '%s' (%s)\n), + bname.buf, + (flags REF_ISBROKEN) ? broken + : (flags REF_ISSYMREF) ? target + : find_unique_abbrev(sha1, DEFAULT_ABBREV)); + continue; + } + if (delete_ref(name, sha1, REF_NODEREF)) { error(remote_branch ? _(Error deleting remote branch '%s') @@ -840,6 +852,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) REF_REMOTE_BRANCH | REF_LOCAL_BRANCH), OPT_BIT('d', delete, delete, N_(delete fully merged branch), 1), OPT_BIT('D', NULL, delete, N_(delete branch (even if not merged)), 2), + OPT__DRY_RUN(branch_delete_show_only, N_(dry run)), OPT_BIT('m', move, rename, N_(move/rename a branch and its reflog), 1), OPT_BIT('M', NULL, rename, N_(move/rename a branch, even if target exists), 2), OPT_BOOL(0, list, list, N_(list branch names)), -- 2.3.0.rc0.286.ga3dc223.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] branch: add support for --dry-run option
This patch adds support -d/--dry-run option for branch(es) deletion. If -d/--dry-run option passed to git branch -d branch..., branch(es) will not be removed, instead just print list of branches that are to be removed. For example: $ git branch a b c * master $ git branch -d -n a b c delete branch 'a' (261c0d1) delete branch 'b' (261c0d1) delete branch 'c' (261c0d1) Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-branch.txt | 11 +-- builtin/branch.c | 13 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 311b336..32ea581 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -16,7 +16,7 @@ SYNOPSIS 'git branch' (--set-upstream-to=upstream | -u upstream) [branchname] 'git branch' --unset-upstream [branchname] 'git branch' (-m | -M) [oldbranch] newbranch -'git branch' (-d | -D) [-r] branchname... +'git branch' (-d | -D) [--dry-run | -n] [-r] branchname... 'git branch' --edit-description [branchname] DESCRIPTION @@ -63,7 +63,9 @@ to happen. With a `-d` or `-D` option, `branchname` will be deleted. You may specify more than one branch for deletion. If the branch currently -has a reflog then the reflog will also be deleted. +has a reflog then the reflog will also be deleted. If passed `-n` or +`--dry-run` option, branch(es) will be not removed, but show a list of +branches that are to be removed. Use `-r` together with `-d` to delete remote-tracking branches. Note, that it only makes sense to delete remote-tracking branches if they no longer exist @@ -83,6 +85,11 @@ OPTIONS -D:: Delete a branch irrespective of its merged status. +-n:: +--dry-run:: + Don't remove the branch(es), but show a list of branches that are + to be removed. + -l:: --create-reflog:: Create the branch's reflog. This activates recording of diff --git a/builtin/branch.c b/builtin/branch.c index d8949cb..4a35a2f 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -61,6 +61,7 @@ static unsigned char merge_filter_ref[20]; static struct string_list output = STRING_LIST_INIT_DUP; static unsigned int colopts; +static int branch_delete_show_only; static int parse_branch_color_slot(const char *slot) { @@ -255,6 +256,17 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, continue; } + if (branch_delete_show_only) { + printf(remote_branch + ? _(delete remote branch '%s' (%s)\n) + : _(delete branch '%s' (%s)\n), + bname.buf, + (flags REF_ISBROKEN) ? broken + : (flags REF_ISSYMREF) ? target + : find_unique_abbrev(sha1, DEFAULT_ABBREV)); + continue; + } + if (delete_ref(name, sha1, REF_NODEREF)) { error(remote_branch ? _(Error deleting remote branch '%s') @@ -840,6 +852,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) REF_REMOTE_BRANCH | REF_LOCAL_BRANCH), OPT_BIT('d', delete, delete, N_(delete fully merged branch), 1), OPT_BIT('D', NULL, delete, N_(delete branch (even if not merged)), 2), + OPT__DRY_RUN(branch_delete_show_only, N_(dry run)), OPT_BIT('m', move, rename, N_(move/rename a branch and its reflog), 1), OPT_BIT('M', NULL, rename, N_(move/rename a branch, even if target exists), 2), OPT_BOOL(0, list, list, N_(list branch names)), -- 2.3.0.rc0.286.ga3dc223.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Documentation/git-branch.txt: add short option to git branch synopsis
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-branch.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 311b336..722f865 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -8,7 +8,7 @@ git-branch - List, create, or delete branches SYNOPSIS [verse] -'git branch' [--color[=when] | --no-color] [-r | -a] +'git branch' [--color[=when] | --no-color] [(-r|--remotes) | (-a|--all)] [--list] [-v [--abbrev=length | --no-abbrev]] [--column[=options] | --no-column] [(--merged | --no-merged | --contains) [commit]] [pattern...] -- 2.3.0.rc0.286.ga3dc223.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] Documentation/init-db.txt: minor style and synopsys fixes
Yes, right, how to do it better? Something like: Documentation, init-db/init:.? Or something else? Thank you 2015-01-15 22:50 GMT+06:00 Eric Sunshine sunsh...@sunshineco.com: On Thu, Jan 15, 2015 at 5:31 AM, Alexander Kuleshov kuleshovm...@gmail.com wrote: Subject: Documentation/init-db.txt: minor style and synopsys fixes Subject is incorrect now that you're modifying git-init-db.txt and git-init.txt. This patch constists of two minor changes: * line-wrap 'git init-db' synopsis * last possible argument '[directory]' was missed Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-init-db.txt | 5 +++-- Documentation/git-init.txt| 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt index 648a6cd..2c77aaa 100644 --- a/Documentation/git-init-db.txt +++ b/Documentation/git-init-db.txt @@ -9,8 +9,9 @@ git-init-db - Creates an empty Git repository SYNOPSIS [verse] -'git init-db' [-q | --quiet] [--bare] [--template=template_directory] [--separate-git-dir git dir] [--shared[=permissions]] - +'git init-db' [-q | --quiet] [--bare] [--template=template_directory] +[--separate-git-dir git-dir] +[--shared[=permissions]] [directory] DESCRIPTION --- diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index 369f889..25412ac 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -10,8 +10,8 @@ SYNOPSIS [verse] 'git init' [-q | --quiet] [--bare] [--template=template_directory] - [--separate-git-dir git dir] - [--shared[=permissions]] [directory] + [--separate-git-dir git-dir] + [--shared[=permissions]] [directory] DESCRIPTION @@ -108,7 +108,7 @@ By default, the configuration flag `receive.denyNonFastForwards` is enabled in shared repositories, so that you cannot force a non fast-forwarding push into it. -If you provide a 'directory', the command is run inside it. If this directory +If you provide a directory, the command is run inside it. If this directory does not exist, it will be created. -- -- 2.3.0.rc0.314.g170a664.dirty -- _ 0xAX -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] stash: added short option '-p' to git stash usage synopsis
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- git-stash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-stash.sh b/git-stash.sh index 6e30380..dc101f9 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -7,7 +7,7 @@ USAGE=list [options] or: $dashless drop [-q|--quiet] [stash] or: $dashless ( pop | apply ) [--index] [-q|--quiet] [stash] or: $dashless branch branchname [stash] - or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet] + or: $dashless [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [message]] or: $dashless clear or: $dashless create [message] -- 2.3.0.rc0.315.g0e14eda -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] string-list: remove print_string_list from string-list's API
print_string_list routine has no callers anywhere. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/technical/api-string-list.txt | 6 -- string-list.c | 10 -- string-list.h | 1 - 3 files changed, 17 deletions(-) diff --git a/Documentation/technical/api-string-list.txt b/Documentation/technical/api-string-list.txt index c08402b..99e12e9 100644 --- a/Documentation/technical/api-string-list.txt +++ b/Documentation/technical/api-string-list.txt @@ -87,12 +87,6 @@ Functions call free() on the util members of any items that have to be deleted. Preserve the order of the items that are retained. -`print_string_list`:: - - Dump a string_list to stdout, useful mainly for debugging purposes. It - can take an optional header argument and it writes out the - string-pointer pairs of the string_list, each one in its own line. - `string_list_clear`:: Free a string_list. The `string` pointer of the items will be freed in diff --git a/string-list.c b/string-list.c index 2a32a3f..ba832da 100644 --- a/string-list.c +++ b/string-list.c @@ -182,16 +182,6 @@ void string_list_clear_func(struct string_list *list, string_list_clear_func_t c list-nr = list-alloc = 0; } - -void print_string_list(const struct string_list *p, const char *text) -{ - int i; - if ( text ) - printf(%s\n, text); - for (i = 0; i p-nr; i++) - printf(%s:%p\n, p-items[i].string, p-items[i].util); -} - struct string_list_item *string_list_append_nodup(struct string_list *list, char *string) { diff --git a/string-list.h b/string-list.h index d3809a1..c417bd5 100644 --- a/string-list.h +++ b/string-list.h @@ -20,7 +20,6 @@ struct string_list { void string_list_init(struct string_list *list, int strdup_strings); -void print_string_list(const struct string_list *p, const char *text); void string_list_clear(struct string_list *list, int free_util); /* Use this function to call a custom clear function on each util pointer */ -- 2.3.0.rc0.315.g0e14eda -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] string-list: remove print_string_list from string-list's API
Maybe need to add comments for print_string_list, for preventing patches like this? 2015-01-15 23:56 GMT+06:00 Junio C Hamano gits...@pobox.com: On Thu, Jan 15, 2015 at 9:42 AM, Alexander Kuleshov kuleshovm...@gmail.com wrote: print_string_list routine has no callers anywhere. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com http://thread.gmane.org/gmane.comp.version-control.git/262439 -- _ 0xAX -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] Documentation/git-init-db.txt: minor style fixes
* line-wrap 'git init-db' synopsis * last possible argument '[directory]' was missed Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-init-db.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt index 648a6cd..b66da6d 100644 --- a/Documentation/git-init-db.txt +++ b/Documentation/git-init-db.txt @@ -9,7 +9,9 @@ git-init-db - Creates an empty Git repository SYNOPSIS [verse] -'git init-db' [-q | --quiet] [--bare] [--template=template_directory] [--separate-git-dir git dir] [--shared[=permissions]] +'git init-db' [-q | --quiet] [--bare] [--template=template-directory] +[--separate-git-dir git-dir] +[--shared[=permissions]] [directory] DESCRIPTION -- 2.3.0.rc0.315.g0e14eda -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] Documentation/git-init.txt: minor style and synopsis fixes
Signed-off-by: 0xAX kuleshovm...@gmail.com --- Documentation/git-init.txt | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index 369f889..f1f0599 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -9,9 +9,9 @@ git-init - Create an empty Git repository or reinitialize an existing one SYNOPSIS [verse] -'git init' [-q | --quiet] [--bare] [--template=template_directory] - [--separate-git-dir git dir] - [--shared[=permissions]] [directory] +'git init' [-q | --quiet] [--bare] [--template=template-directory] + [--separate-git-dir git-dir] + [--shared[=permissions]] [directory] DESCRIPTION @@ -50,12 +50,12 @@ Only print error and warning messages; all other output will be suppressed. Create a bare repository. If GIT_DIR environment is not set, it is set to the current working directory. ---template=template_directory:: +--template=template-directory:: Specify the directory from which templates will be used. (See the TEMPLATE DIRECTORY section below.) ---separate-git-dir=git dir:: +--separate-git-dir=git-dir:: Instead of initializing the repository as a directory to either `$GIT_DIR` or `./.git/`, create a text file there containing the path to the actual @@ -108,7 +108,7 @@ By default, the configuration flag `receive.denyNonFastForwards` is enabled in shared repositories, so that you cannot force a non fast-forwarding push into it. -If you provide a 'directory', the command is run inside it. If this directory +If you provide a directory, the command is run inside it. If this directory does not exist, it will be created. -- -- 2.3.0.rc0.315.g0e14eda -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] init-db: remove unused include
cache.h removed, because it's already included at builtin.h Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/init-db.c | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin/init-db.c b/builtin/init-db.c index 280454a..8edef87 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -3,7 +3,6 @@ * * Copyright (C) Linus Torvalds, 2005 */ -#include cache.h #include builtin.h #include exec_cmd.h #include parse-options.h -- 2.3.0.rc0.256.g2ad8601.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] Documentation/init-db.txt: minor style and synopsys fixes
This patch constists of two minor changes: * line-wrap 'git init-db' synopsis * last possible argument '[directory]' was missed Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-init-db.txt | 5 +++-- Documentation/git-init.txt| 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt index 648a6cd..2c77aaa 100644 --- a/Documentation/git-init-db.txt +++ b/Documentation/git-init-db.txt @@ -9,8 +9,9 @@ git-init-db - Creates an empty Git repository SYNOPSIS [verse] -'git init-db' [-q | --quiet] [--bare] [--template=template_directory] [--separate-git-dir git dir] [--shared[=permissions]] - +'git init-db' [-q | --quiet] [--bare] [--template=template_directory] +[--separate-git-dir git-dir] +[--shared[=permissions]] [directory] DESCRIPTION --- diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index 369f889..25412ac 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -10,8 +10,8 @@ SYNOPSIS [verse] 'git init' [-q | --quiet] [--bare] [--template=template_directory] - [--separate-git-dir git dir] - [--shared[=permissions]] [directory] + [--separate-git-dir git-dir] + [--shared[=permissions]] [directory] DESCRIPTION @@ -108,7 +108,7 @@ By default, the configuration flag `receive.denyNonFastForwards` is enabled in shared repositories, so that you cannot force a non fast-forwarding push into it. -If you provide a 'directory', the command is run inside it. If this directory +If you provide a directory, the command is run inside it. If this directory does not exist, it will be created. -- -- 2.3.0.rc0.314.g170a664.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] init-db: remove unused #includes
Hello Junio, yes right, missed system_path usage. But it's strange, code still compiles successfully without exec_cmd.h. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] init-db: remove unused #includes
* cache.h - is unnecessary because it already included at builtin.h * exec_cmd.h - was added at a47d1813 (Allow a relative builtin template directory., 15 Nov 2007). init-db used 'git_exec_path' routine from exec_cmd.h, but later it was removed at 2de9de5e (Move code interpreting path relative to exec-dir to new function system_path()., 14 Jul 2008). So we no need in it anymore. Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/init-db.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/builtin/init-db.c b/builtin/init-db.c index 280454a..2978b36 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -3,9 +3,7 @@ * * Copyright (C) Linus Torvalds, 2005 */ -#include cache.h #include builtin.h -#include exec_cmd.h #include parse-options.h #ifndef DEFAULT_GIT_TEMPLATE_DIR -- 2.3.0.rc0.255.g53b80d0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] init-db: use OPT__QUIET macro instead OPT_BIT
There is OPT__QUIET macro for easily -q/--quiet option defenition, let's use it instead OPT_BIT Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/init-db.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/builtin/init-db.c b/builtin/init-db.c index 280454a..a89343b 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -368,7 +368,7 @@ static void separate_git_dir(const char *git_dir) write_file(git_link, 1, gitdir: %s\n, git_dir); } -int init_db(const char *template_dir, unsigned int flags) +int init_db(const char *template_dir, unsigned int quiet) { int reinit; const char *git_dir = get_git_dir(); @@ -411,8 +411,7 @@ int init_db(const char *template_dir, unsigned int flags) git_config_set(core.sharedrepository, buf); git_config_set(receive.denyNonFastforwards, true); } - if (!(flags INIT_DB_QUIET)) { + if (!(quiet INIT_DB_QUIET)) { int len = strlen(git_dir); /* TRANSLATORS: The first '%s' is either Reinitialized @@ -483,7 +482,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) const char *real_git_dir = NULL; const char *work_tree; const char *template_dir = NULL; - unsigned int flags = 0; + unsigned int quiet = 0; const struct option init_db_options[] = { OPT_STRING(0, template, template_dir, N_(template-directory), N_(directory from which templates will be used)), @@ -493,7 +492,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) N_(permissions), N_(specify that the git repository is to be shared amongst several users), PARSE_OPT_OPTARG | PARSE_OPT_NONEG, shared_callback, 0}, - OPT_BIT('q', quiet, flags, N_(be quiet), INIT_DB_QUIET), + OPT__QUIET(quiet, N_(suppress progress reporting)), OPT_STRING(0, separate-git-dir, real_git_dir, N_(gitdir), N_(separate git dir from working tree)), OPT_END() @@ -593,5 +592,5 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) set_git_dir_init(git_dir, real_git_dir, 1); - return init_db(template_dir, flags); + return init_db(template_dir, quiet); } -- 2.3.0.rc0.256.g17f147e -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] diff: added '-q' option, short option for '--quiet'
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/diff-options.txt | 1 + diff.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt index 2b15050..9160c90 100644 --- a/Documentation/diff-options.txt +++ b/Documentation/diff-options.txt @@ -491,6 +491,7 @@ ifndef::git-log[] That is, it exits with 1 if there were differences and 0 means no differences. +-q --quiet:: Disable all output of the program. Implies `--exit-code`. endif::git-log[] diff --git a/diff.c b/diff.c index 6ad8970..d778df7 100644 --- a/diff.c +++ b/diff.c @@ -3798,7 +3798,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) } else if (!strcmp(arg, --exit-code)) DIFF_OPT_SET(options, EXIT_WITH_STATUS); - else if (!strcmp(arg, --quiet)) + else if (!strcmp(arg, --quiet) || !strcmp(arg, -q)) DIFF_OPT_SET(options, QUICK); else if (!strcmp(arg, --ext-diff)) DIFF_OPT_SET(options, ALLOW_EXTERNAL); -- 2.3.0.rc0.256.gb0e92c0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Documentation/init-db.txt: minor style and synopsys fixes
This patch constists of two minor changes: * line-wrap 'git init-db' synopsis * last possible argument '[directory]' was missed Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-init-db.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt index 648a6cd..1d94fe8 100644 --- a/Documentation/git-init-db.txt +++ b/Documentation/git-init-db.txt @@ -9,8 +9,9 @@ git-init-db - Creates an empty Git repository SYNOPSIS [verse] -'git init-db' [-q | --quiet] [--bare] [--template=template_directory] [--separate-git-dir git dir] [--shared[=permissions]] - +'git init-db' [-q | --quiet] [--bare] [--template=template_directory] + [--separate-git-dir git dir] + [--shared[=permissions]] [directory] DESCRIPTION --- -- 2.3.0.rc0.256.g0057d96 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] bash completion: allow git stash store options completion
This patch adds bash completion for git stash 'store' subcommand which apperead at bd514cad (stash: introduce 'git stash store', 18 Jun 2013) Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- contrib/completion/git-completion.bash | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index c21190d..7578266 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2375,7 +2375,7 @@ _git_show_branch () _git_stash () { local save_opts='--keep-index --no-keep-index --quiet --patch' - local subcommands='save list show apply clear drop pop create branch' + local subcommands='save list show apply clear drop pop create branch store' local subcommand=$(__git_find_on_cmdline $subcommands) if [ -z $subcommand ]; then case $cur in @@ -2402,6 +2402,9 @@ _git_stash () __gitcomp_nl $(git --git-dir=$(__gitdir) stash list \ | sed -n -e 's/:.*//p') ;; + store,--*) + __gitcomp --message --quiet + ;; *) ;; esac -- 2.3.0.rc0.239.g0ae1f56.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] stash: git stash create and git stash store added to git stash usage synopsys
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- git-stash.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git-stash.sh b/git-stash.sh index 6846b18..6e30380 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -9,7 +9,9 @@ USAGE=list [options] or: $dashless branch branchname [stash] or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [message]] - or: $dashless clear + or: $dashless clear + or: $dashless create [message] + or: $dashless store [-m|--message message] [-q|--quiet] commit SUBDIRECTORY_OK=Yes OPTIONS_SPEC= -- 2.3.0.rc0.239.g0ae1f56.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] format-patch: print format-patch usage if there are no arguments
Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/log.c | 4 1 file changed, 4 insertions(+) diff --git a/builtin/log.c b/builtin/log.c index ad3cfd8..4431b50 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1246,6 +1246,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) OPT_END() }; + /* We need at least one revision */ + if (argc == 1) + usage_with_options(builtin_format_patch_usage, builtin_format_patch_options); + extra_hdr.strdup_strings = 1; extra_to.strdup_strings = 1; extra_cc.strdup_strings = 1; -- 2.3.0.rc0.239.g0ae1f56.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] stash clear: allow -v/--verbose to be passed
Added new option -v/--verbose to 'git stash clear' for verbose output. For example: $ git stash clear -v Removed stash@{0}: WIP on stash-clear-verbose: 0ae1f56 Merge branch 'bp/diff-relative-config' into pu Removed stash@{1}: WIP on stash-clear-verbose: 0ae1f56 Merge branch 'bp/diff-relative-config' into pu Removed stash@{2}: WIP on stash-clear-verbose: 0ae1f56 Merge branch 'bp/diff-relative-config' into pu Removed stash@{3}: WIP on master: addfb21 Git 2.3.0-rc0 Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- Documentation/git-stash.txt | 4 ++-- git-stash.sh| 15 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 375213f..f5b3dd8 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -15,7 +15,7 @@ SYNOPSIS 'git stash' branch branchname [stash] 'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [message]] -'git stash' clear +'git stash' clear [-v|--verbose] 'git stash' create [message] 'git stash' store [-m|--message message] [-q|--quiet] commit @@ -136,7 +136,7 @@ the stash is applied on top of the commit that was HEAD at the time `git stash` was run, it restores the originally stashed state with no conflicts. -clear:: +clear [-v|--verbose]:: Remove all the stashed states. Note that those states will then be subject to pruning, and may be impossible to recover (see 'Examples' below for a possible strategy). diff --git a/git-stash.sh b/git-stash.sh index 6846b18..9f16289 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -9,7 +9,7 @@ USAGE=list [options] or: $dashless branch branchname [stash] or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [message]] - or: $dashless clear + or: $dashless clear [-v|--verbose] SUBDIRECTORY_OK=Yes OPTIONS_SPEC= @@ -46,12 +46,17 @@ untracked_files () { } clear_stash () { - if test $# != 0 - then - die $(gettext git stash clear with parameters is unimplemented) - fi if current=$(git rev-parse --verify --quiet $ref_stash) then + case $1 in + -v|--verbose) + shift + git log --format=%gd: %gs -g --first-parent -m $@ $ref_stash -- | sed -e 's/^/Removed /g' + ;; + *) + break + ;; + esac git update-ref -d $ref_stash $current fi } -- 2.3.0.rc0.239.g0ae1f56.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] format-patch: print format-patch usage if there are no arguments
Hello Junio, As some commands does it when they are executed without arguments, like git config, git blame and etc... 2015-01-14 0:43 GMT+06:00 Junio C Hamano gits...@pobox.com: Why? -- _ 0xAX -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git.c: prevent change of environment variables
We can't change environment variables in aliases which doesn't start with '!' * 'git --exec-path=path' changes $GIT_EXEC_PATH variable in git_set_argv_exec_path * 'git -p/--paginate' sets 'use_pager' to 1 and commit_pager_choice will change $GIT_PAGER_IN_USE variable in setup_pager(void) from pager.c * 'git -c' calls git_config_push_parameter which will change $GIT_CONFIG_PARAMETERS variable Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- git.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/git.c b/git.c index c9bec99..3e87f05 100644 --- a/git.c +++ b/git.c @@ -89,8 +89,11 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) * Check remaining flags. */ if (skip_prefix(cmd, --exec-path, cmd)) { - if (*cmd == '=') + if (*cmd == '=') { git_set_argv_exec_path(cmd + 1); + if (envchanged) + *envchanged = 1; + } else { puts(git_exec_path()); exit(0); @@ -106,6 +109,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) exit(0); } else if (!strcmp(cmd, -p) || !strcmp(cmd, --paginate)) { use_pager = 1; + if (envchanged) + *envchanged = 1; } else if (!strcmp(cmd, --no-pager)) { use_pager = 0; if (envchanged) @@ -171,6 +176,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) usage(git_usage_string); } git_config_push_parameter((*argv)[1]); + if (envchanged) + *envchanged = 1; (*argv)++; (*argc)--; } else if (!strcmp(cmd, --literal-pathspecs)) { -- 2.2.1.531.g5addc96.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] cat-file: remove definition of already defined variables
'enum object_type type' and 'unsigned long size' are already defined at the top of cat_one_file routine Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/cat-file.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 750b5a2..31b133b 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -75,8 +75,6 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name) if (type_from_string(exp_type) == OBJ_BLOB) { unsigned char blob_sha1[20]; if (sha1_object_info(sha1, NULL) == OBJ_TAG) { - enum object_type type; - unsigned long size; char *buffer = read_sha1_file(sha1, type, size); const char *target; if (!skip_prefix(buffer, object , target) || -- 2.2.1.532.g168b885.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] git.c: prevent change of environment variables
There is aliasing of git -c in t1300-repo-config.sh, but I see: die(alias '%s' changes environment variables\n You can use '!git' in the alias to do this., alias_command); at git.c, how to be here? Thank you. 2015-01-10 18:53 GMT+06:00 Alexander Kuleshov kuleshovm...@gmail.com: We can't change environment variables in aliases which doesn't start with '!' * 'git --exec-path=path' changes $GIT_EXEC_PATH variable in git_set_argv_exec_path * 'git -p/--paginate' sets 'use_pager' to 1 and commit_pager_choice will change $GIT_PAGER_IN_USE variable in setup_pager(void) from pager.c * 'git -c' calls git_config_push_parameter which will change $GIT_CONFIG_PARAMETERS variable Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- git.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/git.c b/git.c index c9bec99..3e87f05 100644 --- a/git.c +++ b/git.c @@ -89,8 +89,11 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) * Check remaining flags. */ if (skip_prefix(cmd, --exec-path, cmd)) { - if (*cmd == '=') + if (*cmd == '=') { git_set_argv_exec_path(cmd + 1); + if (envchanged) + *envchanged = 1; + } else { puts(git_exec_path()); exit(0); @@ -106,6 +109,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) exit(0); } else if (!strcmp(cmd, -p) || !strcmp(cmd, --paginate)) { use_pager = 1; + if (envchanged) + *envchanged = 1; } else if (!strcmp(cmd, --no-pager)) { use_pager = 0; if (envchanged) @@ -171,6 +176,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) usage(git_usage_string); } git_config_push_parameter((*argv)[1]); + if (envchanged) + *envchanged = 1; (*argv)++; (*argc)--; } else if (!strcmp(cmd, --literal-pathspecs)) { -- 2.2.1.531.g5addc96.dirty -- _ 0xAX -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] cat-file: remove unnecessary #include
cache.h is already included in builtin.h It appeared at e83c51 (Initial revision of git, the information manager from hell., 8 Apr 2005) and used cache.c API (get_sha1_hex and read_sha1_file). After this in the commit f81dae (Builtin git-cat-file., ) was included builtin.h, which already includes cache.h, so we no need to include it in the cat-file.c Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- builtin/cat-file.c | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 750b5a2..2e6aaa1 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -3,7 +3,6 @@ * * Copyright (C) Linus Torvalds, 2005 */ -#include cache.h #include builtin.h #include parse-options.h #include userdiff.h -- 2.2.1.532.g168b885.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git.c: remove unused includes
* cache.h and commit.h already included in builtin.h * quote.h was appeared in (6035d6aa GIT_TRACE: show which built-in/external commands are executed 25 Jun 2006) and sq_quote_print was removed at (82aae5c quote: remove sq_quote_print() Jul 30 2013) Signed-off-by: Alexander Kuleshov kuleshovm...@gmail.com --- git.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/git.c b/git.c index 09b3bcf..c9bec99 100644 --- a/git.c +++ b/git.c @@ -1,10 +1,7 @@ #include builtin.h -#include cache.h #include exec_cmd.h #include help.h -#include quote.h #include run-command.h -#include commit.h const char git_usage_string[] = git [--version] [--help] [-C path] [-c name=value]\n -- 2.2.1.522.g2561c04.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html