Re: [RFC] [PATCH] remote: add new --fetch option for set-url
From: Peter Wu pe...@lekensteyn.nl Ok, I will make a clear note about the default (without --only) behavior having weird behavior for historical reasons. Are you really OK with --only=both? It sounds a bit odd (mathematically speaking it is correct as fetch and push are both partitions that form the whole set if you ignore the historical behavior). How about : s/--only/--direction/ or some suitable abbreviation (--dirn ?) -- Philip -- 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] introduce git root
This introduces `git root` which outputs the root directory (the directory that contains .git). The same can be accomplished by `git rev-parse --show-toplevel`. `git root` is much more intuitive and easy to remember. All it does is set the arguments for rev-parse Signed-off-by: Arjun Sreedharan arjun...@gmail.com --- Hi, I don't know if I can just send a patch for a new command in git, I probably shouldn't. Well, i thought it's anyway better explaining this way than just asking for comments. With the kind of projects i have been involved with in the recent past, I have had to deal with subprojects inside projects and for many reasons had to find ways to find the root git folder and at times to cd to it. The obvious choice is to go for `git rev-parse --show-toplevel`. But, this to me doesn't seem very _intuitive_ and `git root` does. bzr has `bzr root`. hg has `hg root`. So, for programmers i am guessing this pattern would also be _instinctive_, and i am thinking why not `git root`? Arjun Sreedharan Makefile | 1 + builtin.h | 1 + builtin/root.c | 10 ++ git.c | 1 + 4 files changed, 13 insertions(+) create mode 100644 builtin/root.c diff --git a/Makefile b/Makefile index 827006b..7f28d13 100644 --- a/Makefile +++ b/Makefile @@ -869,6 +869,7 @@ BUILTIN_OBJS += builtin/rev-list.o BUILTIN_OBJS += builtin/rev-parse.o BUILTIN_OBJS += builtin/revert.o BUILTIN_OBJS += builtin/rm.o +BUILTIN_OBJS += builtin/root.o BUILTIN_OBJS += builtin/send-pack.o BUILTIN_OBJS += builtin/shortlog.o BUILTIN_OBJS += builtin/show-branch.o diff --git a/builtin.h b/builtin.h index b87df70..4672d72 100644 --- a/builtin.h +++ b/builtin.h @@ -112,6 +112,7 @@ extern int cmd_rev_list(int argc, const char **argv, const char *prefix); extern int cmd_rev_parse(int argc, const char **argv, const char *prefix); extern int cmd_revert(int argc, const char **argv, const char *prefix); extern int cmd_rm(int argc, const char **argv, const char *prefix); +extern int cmd_root(int argc, const char **argv, const char *prefix); extern int cmd_send_pack(int argc, const char **argv, const char *prefix); extern int cmd_shortlog(int argc, const char **argv, const char *prefix); extern int cmd_show(int argc, const char **argv, const char *prefix); diff --git a/builtin/root.c b/builtin/root.c new file mode 100644 index 000..c2eeca3 --- /dev/null +++ b/builtin/root.c @@ -0,0 +1,10 @@ +#include builtin.h +#include argv-array.h + +int cmd_root(int argc, const char **argv, const char *prefix) +{ + struct argv_array root_args = ARGV_ARRAY_INIT; + + argv_array_pushl(root_args, argv[0], --show-toplevel, NULL); + return cmd_rev_parse(root_args.argc, root_args.argv, prefix); +} diff --git a/git.c b/git.c index 18fbf79..6a0be5f 100644 --- a/git.c +++ b/git.c @@ -461,6 +461,7 @@ static struct cmd_struct commands[] = { { rev-parse, cmd_rev_parse }, { revert, cmd_revert, RUN_SETUP | NEED_WORK_TREE }, { rm, cmd_rm, RUN_SETUP }, + { root, cmd_root, RUN_SETUP }, { send-pack, cmd_send_pack, RUN_SETUP }, { shortlog, cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER }, { show, cmd_show, RUN_SETUP }, -- 1.7.11.7 -- 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] introduce git root
From: Arjun Sreedharan arjun...@gmail.com This introduces `git root` which outputs the root directory (the directory that contains .git). The same can be accomplished by `git rev-parse --show-toplevel`. `git root` is much more intuitive and easy to remember. All it does is set the arguments for rev-parse This may be better as an alias. I've added it to my aliases list. Signed-off-by: Arjun Sreedharan arjun...@gmail.com --- Hi, I don't know if I can just send a patch for a new command in git, I probably shouldn't. Well, i thought it's anyway better explaining this way than just asking for comments. With the kind of projects i have been involved with in the recent past, I have had to deal with subprojects inside projects and for many reasons had to find ways to find the root git folder and at times to cd to it. The obvious choice is to go for `git rev-parse --show-toplevel`. But, this to me doesn't seem very _intuitive_ and `git root` does. bzr has `bzr root`. hg has `hg root`. So, for programmers i am guessing this pattern would also be _instinctive_, and i am thinking why not `git root`? Arjun Sreedharan Makefile | 1 + builtin.h | 1 + builtin/root.c | 10 ++ git.c | 1 + 4 files changed, 13 insertions(+) create mode 100644 builtin/root.c diff --git a/Makefile b/Makefile index 827006b..7f28d13 100644 --- a/Makefile +++ b/Makefile @@ -869,6 +869,7 @@ BUILTIN_OBJS += builtin/rev-list.o BUILTIN_OBJS += builtin/rev-parse.o BUILTIN_OBJS += builtin/revert.o BUILTIN_OBJS += builtin/rm.o +BUILTIN_OBJS += builtin/root.o BUILTIN_OBJS += builtin/send-pack.o BUILTIN_OBJS += builtin/shortlog.o BUILTIN_OBJS += builtin/show-branch.o diff --git a/builtin.h b/builtin.h index b87df70..4672d72 100644 --- a/builtin.h +++ b/builtin.h @@ -112,6 +112,7 @@ extern int cmd_rev_list(int argc, const char **argv, const char *prefix); extern int cmd_rev_parse(int argc, const char **argv, const char *prefix); extern int cmd_revert(int argc, const char **argv, const char *prefix); extern int cmd_rm(int argc, const char **argv, const char *prefix); +extern int cmd_root(int argc, const char **argv, const char *prefix); extern int cmd_send_pack(int argc, const char **argv, const char *prefix); extern int cmd_shortlog(int argc, const char **argv, const char *prefix); extern int cmd_show(int argc, const char **argv, const char *prefix); diff --git a/builtin/root.c b/builtin/root.c new file mode 100644 index 000..c2eeca3 --- /dev/null +++ b/builtin/root.c @@ -0,0 +1,10 @@ +#include builtin.h +#include argv-array.h + +int cmd_root(int argc, const char **argv, const char *prefix) +{ + struct argv_array root_args = ARGV_ARRAY_INIT; + + argv_array_pushl(root_args, argv[0], --show-toplevel, NULL); + return cmd_rev_parse(root_args.argc, root_args.argv, prefix); +} diff --git a/git.c b/git.c index 18fbf79..6a0be5f 100644 --- a/git.c +++ b/git.c @@ -461,6 +461,7 @@ static struct cmd_struct commands[] = { { rev-parse, cmd_rev_parse }, { revert, cmd_revert, RUN_SETUP | NEED_WORK_TREE }, { rm, cmd_rm, RUN_SETUP }, + { root, cmd_root, RUN_SETUP }, { send-pack, cmd_send_pack, RUN_SETUP }, { shortlog, cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER }, { show, cmd_show, RUN_SETUP }, -- 1.7.11.7 -- Philip -- 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
git status / git diff -C not detecting file copy
Hi, The documentation for git status at http://git-scm.com/docs/git-status implies that it should be able to detect both renames and copies (with the R and C states). The command git diff -C should do it as well. However I can't get either to detect copies in this simple test case - what is happening? mkdir test cd test/ git init echo 'Hello World!' hello.txt echo 'Goodbye World!' goodbye.txt git add -A git commit -m Initial commit cp hello.txt copied.txt mv goodbye.txt moved.txt git add -A $ git status --short A copied.txt NO COPY DETECTED R goodbye.txt - moved.txt $ git diff -M -C --summary --cached create mode 100644 copied.txt NO COPY DETECTED rename goodbye.txt = moved.txt (100%) $ git commit -m Test $ git diff -M -C --summary HEAD~ create mode 100644 copied.txt NO COPY DETECTED rename goodbye.txt = moved.txt (100%) -Pol -- 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: git status / git diff -C not detecting file copy
Pol, By default, -C only finds copies when the source file was also modified in the same commit. Since you did not modify hello.txt in the same commit where you copied it to copied.txt, it will not be considered. If you pass -C -C (twice), or use --find-copies-harder, Git will consider all files in the repository. Note that this can be slower, which is the reason why it's not the default. The documentation for git diff describes the -C (--find-copies) and --find-copies-harder flags and their limitations. Hope this helps, Bryan Turner On Sun, Nov 30, 2014 at 11:35 AM, Pol Online i...@pol-online.net wrote: Hi, The documentation for git status at http://git-scm.com/docs/git-status implies that it should be able to detect both renames and copies (with the R and C states). The command git diff -C should do it as well. However I can't get either to detect copies in this simple test case - what is happening? mkdir test cd test/ git init echo 'Hello World!' hello.txt echo 'Goodbye World!' goodbye.txt git add -A git commit -m Initial commit cp hello.txt copied.txt mv goodbye.txt moved.txt git add -A $ git status --short A copied.txt NO COPY DETECTED R goodbye.txt - moved.txt $ git diff -M -C --summary --cached create mode 100644 copied.txt NO COPY DETECTED rename goodbye.txt = moved.txt (100%) $ git commit -m Test $ git diff -M -C --summary HEAD~ create mode 100644 copied.txt NO COPY DETECTED rename goodbye.txt = moved.txt (100%) -Pol -- 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 -- 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: git status / git diff -C not detecting file copy
Hi Bryan, OK that explains the behavior of git diff, but what about git status? The doc implies it should be able to detect copies in the index / staging area since it has a C state. - Pol On Sun, Nov 30, 2014 at 10:03 AM, Bryan Turner btur...@atlassian.com wrote: Pol, By default, -C only finds copies when the source file was also modified in the same commit. Since you did not modify hello.txt in the same commit where you copied it to copied.txt, it will not be considered. If you pass -C -C (twice), or use --find-copies-harder, Git will consider all files in the repository. Note that this can be slower, which is the reason why it's not the default. The documentation for git diff describes the -C (--find-copies) and --find-copies-harder flags and their limitations. Hope this helps, Bryan Turner On Sun, Nov 30, 2014 at 11:35 AM, Pol Online i...@pol-online.net wrote: Hi, The documentation for git status at http://git-scm.com/docs/git-status implies that it should be able to detect both renames and copies (with the R and C states). The command git diff -C should do it as well. However I can't get either to detect copies in this simple test case - what is happening? mkdir test cd test/ git init echo 'Hello World!' hello.txt echo 'Goodbye World!' goodbye.txt git add -A git commit -m Initial commit cp hello.txt copied.txt mv goodbye.txt moved.txt git add -A $ git status --short A copied.txt NO COPY DETECTED R goodbye.txt - moved.txt $ git diff -M -C --summary --cached create mode 100644 copied.txt NO COPY DETECTED rename goodbye.txt = moved.txt (100%) $ git commit -m Test $ git diff -M -C --summary HEAD~ create mode 100644 copied.txt NO COPY DETECTED rename goodbye.txt = moved.txt (100%) -Pol -- 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 -- 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: git status / git diff -C not detecting file copy
Pol, It's the same set of limitations. Git does not track renames or copies as such. It uses heuristics to compute a similarity index and then decide. All the tree stores for your copy is a file add, and that's the status you're seeing. I don't think there is any way to turn on aggressive copy detection for git status. However, before you run git commit, you could run git diff --find-copies-harder --cached instead and it should show the copy. I'll let someone a little more intimately familiar with the internals of git status comment on why the documentation for that mentions copies. Hope this helps, Bryan Turner On Sun, Nov 30, 2014 at 12:30 PM, Pol Online i...@pol-online.net wrote: Hi Bryan, OK that explains the behavior of git diff, but what about git status? The doc implies it should be able to detect copies in the index / staging area since it has a C state. - Pol On Sun, Nov 30, 2014 at 10:03 AM, Bryan Turner btur...@atlassian.com wrote: Pol, By default, -C only finds copies when the source file was also modified in the same commit. Since you did not modify hello.txt in the same commit where you copied it to copied.txt, it will not be considered. If you pass -C -C (twice), or use --find-copies-harder, Git will consider all files in the repository. Note that this can be slower, which is the reason why it's not the default. The documentation for git diff describes the -C (--find-copies) and --find-copies-harder flags and their limitations. Hope this helps, Bryan Turner On Sun, Nov 30, 2014 at 11:35 AM, Pol Online i...@pol-online.net wrote: Hi, The documentation for git status at http://git-scm.com/docs/git-status implies that it should be able to detect both renames and copies (with the R and C states). The command git diff -C should do it as well. However I can't get either to detect copies in this simple test case - what is happening? mkdir test cd test/ git init echo 'Hello World!' hello.txt echo 'Goodbye World!' goodbye.txt git add -A git commit -m Initial commit cp hello.txt copied.txt mv goodbye.txt moved.txt git add -A $ git status --short A copied.txt NO COPY DETECTED R goodbye.txt - moved.txt $ git diff -M -C --summary --cached create mode 100644 copied.txt NO COPY DETECTED rename goodbye.txt = moved.txt (100%) $ git commit -m Test $ git diff -M -C --summary HEAD~ create mode 100644 copied.txt NO COPY DETECTED rename goodbye.txt = moved.txt (100%) -Pol -- 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 -- 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] compat: convert modes to use portable file type values
This adds simple wrapper functions around calls to stat(), fstat(), and lstat() that translate the operating system's native file type bits to those used by most operating systems. It also rewrites the S_IF* macros to the common values, so all file type processing is performed using the translated modes. This makes projects portable across operating systems that use different file type definitions. Only the file type bits may be affected by these compatibility functions; the file permission bits are assumed to be 0 and are passed through unchanged. Signed-off-by: David Michael fedora@gmail.com --- Hi, This is my most recent attempt at solving the problem of z/OS using different file type values than every other OS. I believe it should be safe as long as the file type bits don't ever need to be converted back to their native values (and I didn't see any instances of that). I've been testing it by making commits to the same repositories on different operating systems and pushing those changes around, and so far there have been no issues. Can anyone foresee any problems with this method? Thanks. David Makefile | 8 cache.h | 7 --- compat/stat.c | 49 + configure.ac | 22 ++ git-compat-util.h | 32 5 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 compat/stat.c diff --git a/Makefile b/Makefile index 827006b..cba3be1 100644 --- a/Makefile +++ b/Makefile @@ -191,6 +191,10 @@ all:: # Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support # the executable mode bit, but doesn't really do so. # +# Define NEEDS_MODE_TRANSLATION if your OS strays from the typical file type +# bits in mode values (e.g. z/OS defines I_SFMT to 0xFF00 as opposed to the +# usual 0xF000). +# # Define NO_IPV6 if you lack IPv6 support and getaddrinfo(). # # Define NO_UNIX_SOCKETS if your system does not offer unix sockets. @@ -1230,6 +1234,10 @@ endif ifdef NO_TRUSTABLE_FILEMODE BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE endif +ifdef NEEDS_MODE_TRANSLATION + COMPAT_CFLAGS += -DNEEDS_MODE_TRANSLATION + COMPAT_OBJS += compat/stat.o +endif ifdef NO_IPV6 BASIC_CFLAGS += -DNO_IPV6 endif diff --git a/cache.h b/cache.h index 99ed096..f8174fe 100644 --- a/cache.h +++ b/cache.h @@ -65,13 +65,6 @@ unsigned long git_deflate_bound(git_zstream *, unsigned long); * * The value 016 is not normally a valid mode, and * also just happens to be S_IFDIR + S_IFLNK - * - * NOTE! We *really* shouldn't depend on the S_IFxxx macros - * always having the same values everywhere. We should use - * our internal git values for these things, and then we can - * translate that to the OS-specific value. It just so - * happens that everybody shares the same bit representation - * in the UNIX world (and apparently wider too..) */ #define S_IFGITLINK016 #define S_ISGITLINK(m) (((m) S_IFMT) == S_IFGITLINK) diff --git a/compat/stat.c b/compat/stat.c new file mode 100644 index 000..0ff1f2f --- /dev/null +++ b/compat/stat.c @@ -0,0 +1,49 @@ +#define _POSIX_SOURCE +#include stddef.h/* NULL */ +#include sys/stat.h /* *stat, S_IS* */ +#include sys/types.h /* mode_t */ + +static inline mode_t mode_native_to_git(mode_t native_mode) +{ + if (S_ISREG(native_mode)) + return 010 | (native_mode 0); + else if (S_ISDIR(native_mode)) + return 004 | (native_mode 0); + else if (S_ISLNK(native_mode)) + return 012 | (native_mode 0); + else if (S_ISBLK(native_mode)) + return 006 | (native_mode 0); + else if (S_ISCHR(native_mode)) + return 002 | (native_mode 0); + else if (S_ISFIFO(native_mode)) + return 001 | (native_mode 0); + else /* Non-standard type bits were given. */ + return native_mode 0; +} + +int git_stat(const char *path, struct stat *buf) +{ + int rc; + rc = stat(path, buf); + if (buf != NULL) + buf-st_mode = mode_native_to_git(buf-st_mode); + return rc; +} + +int git_fstat(int fd, struct stat *buf) +{ + int rc; + rc = fstat(fd, buf); + if (buf != NULL) + buf-st_mode = mode_native_to_git(buf-st_mode); + return rc; +} + +int git_lstat(const char *path, struct stat *buf) +{ + int rc; + rc = lstat(path, buf); + if (buf != NULL) + buf-st_mode = mode_native_to_git(buf-st_mode); + return rc; +} diff --git a/configure.ac b/configure.ac index 6af9647..b8eced4 100644 --- a/configure.ac +++ b/configure.ac @@ -873,6 +873,28 @@ else SNPRINTF_RETURNS_BOGUS= fi GIT_CONF_SUBST([SNPRINTF_RETURNS_BOGUS]) +# +# Define NEEDS_MODE_TRANSLATION if your OS strays from the typical file type +# bits in mode
Re: [PATCH] introduce git root
On 30 November 2014 at 04:38, Philip Oakley philipoak...@iee.org wrote: From: Arjun Sreedharan arjun...@gmail.com This introduces `git root` which outputs the root directory (the directory that contains .git). The same can be accomplished by `git rev-parse --show-toplevel`. `git root` is much more intuitive and easy to remember. All it does is set the arguments for rev-parse This may be better as an alias. I've added it to my aliases list. I know that. I am suggesting this to be a built-in command, without having the need to add as an alias. Signed-off-by: Arjun Sreedharan arjun...@gmail.com --- Hi, I don't know if I can just send a patch for a new command in git, I probably shouldn't. Well, i thought it's anyway better explaining this way than just asking for comments. With the kind of projects i have been involved with in the recent past, I have had to deal with subprojects inside projects and for many reasons had to find ways to find the root git folder and at times to cd to it. The obvious choice is to go for `git rev-parse --show-toplevel`. But, this to me doesn't seem very _intuitive_ and `git root` does. bzr has `bzr root`. hg has `hg root`. So, for programmers i am guessing this pattern would also be _instinctive_, and i am thinking why not `git root`? Arjun Sreedharan Makefile | 1 + builtin.h | 1 + builtin/root.c | 10 ++ git.c | 1 + 4 files changed, 13 insertions(+) create mode 100644 builtin/root.c diff --git a/Makefile b/Makefile index 827006b..7f28d13 100644 --- a/Makefile +++ b/Makefile @@ -869,6 +869,7 @@ BUILTIN_OBJS += builtin/rev-list.o BUILTIN_OBJS += builtin/rev-parse.o BUILTIN_OBJS += builtin/revert.o BUILTIN_OBJS += builtin/rm.o +BUILTIN_OBJS += builtin/root.o BUILTIN_OBJS += builtin/send-pack.o BUILTIN_OBJS += builtin/shortlog.o BUILTIN_OBJS += builtin/show-branch.o diff --git a/builtin.h b/builtin.h index b87df70..4672d72 100644 --- a/builtin.h +++ b/builtin.h @@ -112,6 +112,7 @@ extern int cmd_rev_list(int argc, const char **argv, const char *prefix); extern int cmd_rev_parse(int argc, const char **argv, const char *prefix); extern int cmd_revert(int argc, const char **argv, const char *prefix); extern int cmd_rm(int argc, const char **argv, const char *prefix); +extern int cmd_root(int argc, const char **argv, const char *prefix); extern int cmd_send_pack(int argc, const char **argv, const char *prefix); extern int cmd_shortlog(int argc, const char **argv, const char *prefix); extern int cmd_show(int argc, const char **argv, const char *prefix); diff --git a/builtin/root.c b/builtin/root.c new file mode 100644 index 000..c2eeca3 --- /dev/null +++ b/builtin/root.c @@ -0,0 +1,10 @@ +#include builtin.h +#include argv-array.h + +int cmd_root(int argc, const char **argv, const char *prefix) +{ + struct argv_array root_args = ARGV_ARRAY_INIT; + + argv_array_pushl(root_args, argv[0], --show-toplevel, NULL); + return cmd_rev_parse(root_args.argc, root_args.argv, prefix); +} diff --git a/git.c b/git.c index 18fbf79..6a0be5f 100644 --- a/git.c +++ b/git.c @@ -461,6 +461,7 @@ static struct cmd_struct commands[] = { { rev-parse, cmd_rev_parse }, { revert, cmd_revert, RUN_SETUP | NEED_WORK_TREE }, { rm, cmd_rm, RUN_SETUP }, + { root, cmd_root, RUN_SETUP }, { send-pack, cmd_send_pack, RUN_SETUP }, { shortlog, cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER }, { show, cmd_show, RUN_SETUP }, -- 1.7.11.7 -- Philip -- 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