Staging
v0.5.1
Revision 7d09fbe4ab7f080a8f8f5dcef7e0f3edf5e26019 authored by Serge E. Hallyn on 18 April 2006, 13:11:06 UTC, committed by Junio C Hamano on 25 April 2006, 06:07:54 UTC
The set_reuse_addr() error case was the only error case in
socklist() where we returned rather than continued.  Not sure
why.  Either we must free the socklist, or continue.  This patch
continues on error.

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
(cherry picked from 0032d548db56eac9ea09b4ba05843365f6325b85 commit)
1 parent 1ab661d
Raw File
symbolic-ref.c
#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;
}
back to top