]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-rev-parse.c
"git-fetch --tags $URL" should not overwrite existing tags
[thirdparty/git.git] / builtin-rev-parse.c
index b3e4386c1baec7c3a56704e61e44e575203ab759..d53deaa3691c7b57e215f3f33c44881c4f397527 100644 (file)
 #define DO_NONFLAGS    8
 static int filter = ~0;
 
-static const char *def = NULL;
+static const char *def;
 
 #define NORMAL 0
 #define REVERSED 1
 static int show_type = NORMAL;
-static int symbolic = 0;
-static int abbrev = 0;
-static int output_sq = 0;
+static int symbolic;
+static int abbrev;
+static int output_sq;
 
-static int revs_count = 0;
+static int revs_count;
 
 /*
  * Some arguments are relevant "revision" arguments,
@@ -137,7 +137,7 @@ static void show_default(void)
        }
 }
 
-static int show_reference(const char *refname, const unsigned char *sha1)
+static int show_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
 {
        show_rev(NORMAL, sha1, refname);
        return 0;
@@ -209,11 +209,10 @@ static int try_difference(const char *arg)
        return 0;
 }
 
-int cmd_rev_parse(int argc, const char **argv, char **envp)
+int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 {
        int i, as_is = 0, verify = 0;
        unsigned char sha1[20];
-       const char *prefix = setup_git_directory();
 
        git_config(git_default_config);
 
@@ -300,19 +299,19 @@ int cmd_rev_parse(int argc, const char **argv, char **envp)
                                continue;
                        }
                        if (!strcmp(arg, "--all")) {
-                               for_each_ref(show_reference);
+                               for_each_ref(show_reference, NULL);
                                continue;
                        }
                        if (!strcmp(arg, "--branches")) {
-                               for_each_branch_ref(show_reference);
+                               for_each_branch_ref(show_reference, NULL);
                                continue;
                        }
                        if (!strcmp(arg, "--tags")) {
-                               for_each_tag_ref(show_reference);
+                               for_each_tag_ref(show_reference, NULL);
                                continue;
                        }
                        if (!strcmp(arg, "--remotes")) {
-                               for_each_remote_ref(show_reference);
+                               for_each_remote_ref(show_reference, NULL);
                                continue;
                        }
                        if (!strcmp(arg, "--show-prefix")) {
@@ -348,6 +347,11 @@ int cmd_rev_parse(int argc, const char **argv, char **envp)
                                printf("%s/.git\n", cwd);
                                continue;
                        }
+                       if (!strcmp(arg, "--is-inside-git-dir")) {
+                               printf("%s\n", is_inside_git_dir() ? "true"
+                                               : "false");
+                               continue;
+                       }
                        if (!strncmp(arg, "--since=", 8)) {
                                show_datestring("--max-age=", arg+8);
                                continue;