summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 918008b)
raw | patch | inline | side by side (parent: 918008b)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 28 Dec 2008 18:29:42 +0000 (13:29 -0500) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 28 Dec 2008 19:58:28 +0000 (14:58 -0500) |
Add is_initial_commit macro which replaces opt_no_head tests. Also,
update ref_head and ref_commit with the resolved HEAD revision.
update ref_head and ref_commit with the resolved HEAD revision.
tig.c | patch | blob | history |
index 8059202b919e31b85e4aca248f8065bca4d604f6..6e5b0b4b9e131db046d322deacefada5079bb5b4 100644 (file)
--- a/tig.c
+++ b/tig.c
static char opt_file[SIZEOF_STR] = "";
static char opt_ref[SIZEOF_REF] = "";
static char opt_head[SIZEOF_REF] = "";
+static char opt_head_rev[SIZEOF_REV] = "";
static char opt_remote[SIZEOF_REF] = "";
-static bool opt_no_head = TRUE;
static FILE *opt_pipe = NULL;
static char opt_encoding[20] = "UTF-8";
static bool opt_utf8 = TRUE;
static char opt_editor[SIZEOF_STR] = "";
static FILE *opt_tty = NULL;
+#define is_initial_commit() (!*opt_head_rev)
+
static enum request
parse_options(int argc, const char *argv[])
{
return FALSE;
add_line_data(view, NULL, LINE_STAT_HEAD);
- if (opt_no_head)
+ if (is_initial_commit())
string_copy(status_onbranch, "Initial commit");
else if (!*opt_head)
string_copy(status_onbranch, "Not currently on any branch");
system("git update-index -q --refresh >/dev/null 2>/dev/null");
- if (opt_no_head) {
+ if (is_initial_commit()) {
if (!status_run(view, STATUS_LIST_NO_HEAD_CMD, 'A', LINE_STAT_STAGED))
return FALSE;
} else if (!status_run(view, STATUS_DIFF_INDEX_CMD, 0, LINE_STAT_STAGED)) {
switch (line->type) {
case LINE_STAT_STAGED:
- if (opt_no_head) {
+ if (is_initial_commit()) {
if (!string_format_from(opt_cmd, &cmdsize,
STATUS_DIFF_NO_HEAD_SHOW_CMD,
newpath))
{
struct line *chunk = NULL;
- if (!opt_no_head && stage_line_type != LINE_STAT_UNTRACKED)
+ if (!is_initial_commit() && stage_line_type != LINE_STAT_UNTRACKED)
chunk = stage_diff_find(view, line, LINE_DIFF_CHUNK);
if (chunk) {
{
struct line *chunk = NULL;
- if (!opt_no_head && stage_line_type == LINE_STAT_UNSTAGED)
+ if (!is_initial_commit() && stage_line_type == LINE_STAT_UNSTAGED)
chunk = stage_diff_find(view, line, LINE_DIFF_CHUNK);
if (chunk) {
head = !strncmp(opt_head, name, namelen);
} else if (!strcmp(name, "HEAD")) {
- opt_no_head = FALSE;
+ string_ncopy(opt_head_rev, id, idlen);
return OK;
}