summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6441363)
raw | patch | inline | side by side (parent: 6441363)
author | Matthias Kestenholz <matthias@spinlock.ch> | |
Thu, 3 Aug 2006 15:24:38 +0000 (17:24 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 4 Aug 2006 06:15:11 +0000 (23:15 -0700) |
Signed-off-by: Matthias Kestenholz <matthias@spinlock.ch>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Makefile | patch | blob | history | |
builtin-symbolic-ref.c | [new file with mode: 0644] | patch | blob |
builtin.h | patch | blob | history | |
git.c | patch | blob | history | |
symbolic-ref.c | [deleted file] | patch | blob | history |
diff --git a/Makefile b/Makefile
index b108a8aa7af92206c8aecb5fb9513593089ca601..db59e00ede5728a666f165bf767dd017d3d7469d 100644 (file)
--- a/Makefile
+++ b/Makefile
git-ssh-upload$X git-unpack-file$X \
git-update-server-info$X \
git-upload-pack$X git-verify-pack$X \
- git-symbolic-ref$X \
git-pack-redundant$X git-var$X \
git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X \
git-fmt-merge-msg$X git-prune$X git-mv$X git-prune-packed$X \
git-repo-config$X git-name-rev$X git-pack-objects$X \
- git-unpack-objects$X
+ git-unpack-objects$X git-symbolic-ref$X
# what 'all' will build and 'install' will install, in gitexecdir
ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
builtin-cat-file.o builtin-mailsplit.o builtin-stripspace.o \
builtin-update-ref.o builtin-fmt-merge-msg.o builtin-prune.o \
builtin-mv.o builtin-prune-packed.o builtin-repo-config.o \
- builtin-name-rev.o builtin-pack-objects.o builtin-unpack-objects.o
+ builtin-name-rev.o builtin-pack-objects.o builtin-unpack-objects.o \
+ builtin-symbolic-ref.o
GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
LIBS = $(GITLIBS) -lz
diff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c
--- /dev/null
+++ b/builtin-symbolic-ref.c
@@ -0,0 +1,35 @@
+#include "builtin.h"
+#include "cache.h"
+
+static const char git_symbolic_ref_usage[] =
+"git-symbolic-ref name [ref]";
+
+static void check_symref(const char *HEAD)
+{
+ unsigned char sha1[20];
+ const char *git_HEAD = strdup(git_path("%s", HEAD));
+ const char *git_refs_heads_master = resolve_ref(git_HEAD, sha1, 0);
+ if (git_refs_heads_master) {
+ /* we want to strip the .git/ part */
+ int pfxlen = strlen(git_HEAD) - strlen(HEAD);
+ puts(git_refs_heads_master + pfxlen);
+ }
+ else
+ die("No such ref: %s", HEAD);
+}
+
+int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
+{
+ git_config(git_default_config);
+ switch (argc) {
+ case 2:
+ check_symref(argv[1]);
+ break;
+ case 3:
+ create_symref(strdup(git_path("%s", argv[1])), argv[2]);
+ break;
+ default:
+ usage(git_symbolic_ref_usage);
+ }
+ return 0;
+}
diff --git a/builtin.h b/builtin.h
index af73c3c19e6b255cd90d69e0b5da9069d3732b91..b767245c7559b31d46936343dd02651fa86fdbea 100644 (file)
--- a/builtin.h
+++ b/builtin.h
extern int cmd_name_rev(int argc, const char **argv, const char *prefix);
extern int cmd_pack_objects(int argc, const char **argv, const char *prefix);
extern int cmd_unpack_objects(int argc, const char **argv, const char *prefix);
+extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);
extern int cmd_write_tree(int argc, const char **argv, const char *prefix);
extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix);
index 7c3a7f8fd156a75b0912043d53a54d8b169851a0..e40e85935ca084d784905f3565a2a7555e11e064 100644 (file)
--- a/git.c
+++ b/git.c
{ "name-rev", cmd_name_rev, NEEDS_PREFIX },
{ "pack-objects", cmd_pack_objects, NEEDS_PREFIX },
{ "unpack-objects", cmd_unpack_objects, NEEDS_PREFIX },
+ { "symbolic-ref", cmd_symbolic_ref, NEEDS_PREFIX },
};
int i;
diff --git a/symbolic-ref.c b/symbolic-ref.c
--- a/symbolic-ref.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "cache.h"
-
-static const char git_symbolic_ref_usage[] =
-"git-symbolic-ref name [ref]";
-
-static void check_symref(const char *HEAD)
-{
- unsigned char sha1[20];
- const char *git_HEAD = strdup(git_path("%s", HEAD));
- const char *git_refs_heads_master = resolve_ref(git_HEAD, sha1, 0);
- if (git_refs_heads_master) {
- /* we want to strip the .git/ part */
- int pfxlen = strlen(git_HEAD) - strlen(HEAD);
- puts(git_refs_heads_master + pfxlen);
- }
- else
- die("No such ref: %s", HEAD);
-}
-
-int main(int argc, const char **argv)
-{
- setup_git_directory();
- git_config(git_default_config);
- switch (argc) {
- case 2:
- check_symref(argv[1]);
- break;
- case 3:
- create_symref(strdup(git_path("%s", argv[1])), argv[2]);
- break;
- default:
- usage(git_symbolic_ref_usage);
- }
- return 0;
-}