summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6c5f9ba)
raw | patch | inline | side by side (parent: 6c5f9ba)
author | Jason Riedy <ejr@cs.berkeley.edu> | |
Tue, 23 Aug 2005 20:34:07 +0000 (13:34 -0700) | ||
committer | Jason Riedy <ejr@cs.berkeley.edu> | |
Wed, 24 Aug 2005 03:41:12 +0000 (20:41 -0700) |
Omitting the first branch in ?: is a GNU extension. Cute,
but not supported by other compilers. Replaced mostly
by explicit tests. Calls to getenv() simply are repeated
on non-GNU compilers.
Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
but not supported by other compilers. Replaced mostly
by explicit tests. Calls to getenv() simply are repeated
on non-GNU compilers.
Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
apply.c | patch | blob | history | |
cache.h | patch | blob | history | |
connect.c | patch | blob | history | |
diff.c | patch | blob | history | |
fsck-cache.c | patch | blob | history | |
path.c | patch | blob | history | |
pull.c | patch | blob | history | |
rsh.c | patch | blob | history | |
sha1_file.c | patch | blob | history | |
ssh-pull.c | patch | blob | history | |
ssh-push.c | patch | blob | history |
index 7c1a8411f21ee42d095e6c5a515987ef2a6f779a..ee59be643eb5f95ed021921b1b76d37135cab5ac 100644 (file)
--- a/apply.c
+++ b/apply.c
static int use_patch(struct patch *p)
{
- const char *pathname = p->new_name ? : p->old_name;
+ const char *pathname = p->new_name ? p->new_name : p->old_name;
struct excludes *x = excludes;
while (x) {
if (fnmatch(x->path, pathname, 0) == 0)
index e7f5a2e16fa86111b576f9fae558cbbda2f1a050..e4f4664572ae3b6d58f04a87fe57ab8b460dd48f 100644 (file)
--- a/cache.h
+++ b/cache.h
* We accept older names for now but warn.
*/
extern char *gitenv_bc(const char *);
+#ifdef __GNUC__
#define gitenv(e) (getenv(e) ? : gitenv_bc(e))
+#else
+#define gitenv(e) (getenv(e) ? getenv(e) : gitenv_bc(e))
+#endif
/*
* Basic data structures for the directory cache
diff --git a/connect.c b/connect.c
index a6657b13848b5474ffde7edb0ad60ed969f22852..c0bf869e96ea1189209c3d0bbef6fc27b2499581 100644 (file)
--- a/connect.c
+++ b/connect.c
close(pipefd[1][0]);
close(pipefd[1][1]);
if (protocol == PROTO_SSH) {
- const char *ssh = getenv("GIT_SSH") ? : "ssh";
- const char *ssh_basename = strrchr(ssh, '/');
+ const char *ssh, *ssh_basename;
+ ssh = getenv("GIT_SSH");
+ if (!ssh) ssh = "ssh";
+ ssh_basename = strrchr(ssh, '/');
if (!ssh_basename)
ssh_basename = ssh;
else
index 137d0d0c0c3eaaaa1c3c874c6e5f719e00a0d396..9015c81d76b4038bf5cc567aa2e055370b6ffee8 100644 (file)
--- a/diff.c
+++ b/diff.c
{
static const char *external_diff_cmd = NULL;
static int done_preparing = 0;
+ const char *env_diff_opts;
if (done_preparing)
return external_diff_cmd;
*
* GIT_DIFF_OPTS="-c";
*/
- if (gitenv("GIT_EXTERNAL_DIFF"))
- external_diff_cmd = gitenv("GIT_EXTERNAL_DIFF");
+ external_diff_cmd = gitenv("GIT_EXTERNAL_DIFF");
/* In case external diff fails... */
- diff_opts = gitenv("GIT_DIFF_OPTS") ? : diff_opts;
+ env_diff_opts = gitenv("GIT_DIFF_OPTS");
+ if (env_diff_opts) diff_opts = env_diff_opts;
done_preparing = 1;
return external_diff_cmd;
pid_t pid;
int status;
static int atexit_asked = 0;
+ const char *othername;
+ othername = (other? other : name);
if (one && two) {
prepare_temp_file(name, &temp[0], one);
- prepare_temp_file(other ? : name, &temp[1], two);
+ prepare_temp_file(othername, &temp[1], two);
if (! atexit_asked &&
(temp[0].name == temp[0].tmp_path ||
temp[1].name == temp[1].tmp_path)) {
* otherwise we use the built-in one.
*/
if (one && two)
- builtin_diff(name, other ? : name, temp, xfrm_msg,
+ builtin_diff(name, othername, temp, xfrm_msg,
complete_rewrite);
else
printf("* Unmerged path %s\n", name);
void diff_debug_filespec(struct diff_filespec *s, int x, const char *one)
{
fprintf(stderr, "queue[%d] %s (%s) %s %06o %s\n",
- x, one ? : "",
+ x, one ? one : "",
s->path,
DIFF_FILE_VALID(s) ? "valid" : "invalid",
s->mode,
s->sha1_valid ? sha1_to_hex(s->sha1) : "");
fprintf(stderr, "queue[%d] %s size %lu flags %d\n",
- x, one ? : "",
+ x, one ? one : "",
s->size, s->xfrm_flags);
}
diff_debug_filespec(p->one, i, "one");
diff_debug_filespec(p->two, i, "two");
fprintf(stderr, "score %d, status %c stays %d broken %d\n",
- p->score, p->status ? : '?',
+ p->score, p->status ? p->status : '?',
p->source_stays, p->broken_pair);
}
diff --git a/fsck-cache.c b/fsck-cache.c
index 8091780193b94c9855855656538c64f4a707a212..ca24a1b8449d71195a0e798bce4ec27167bf0aac 100644 (file)
--- a/fsck-cache.c
+++ b/fsck-cache.c
char hex[40];
unsigned char sha1[20];
static char path[PATH_MAX], link[PATH_MAX];
- const char *git_dir = gitenv(GIT_DIR_ENVIRONMENT) ? : DEFAULT_GIT_DIR_ENVIRONMENT;
+ const char *git_dir;
+
+ git_dir = gitenv(GIT_DIR_ENVIRONMENT);
+ if (!git_dir) git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
snprintf(path, sizeof(path), "%s/HEAD", git_dir);
if (readlink(path, link, sizeof(link)) < 0)
index b85f087f4390f1235a6b9e9545b3f6dd8457fdd5..142e575e5c293b92ff8a5612c7acc86d050c1119 100644 (file)
--- a/path.c
+++ b/path.c
char *git_path(const char *fmt, ...)
{
- const char *git_dir = gitenv(GIT_DIR_ENVIRONMENT) ? : DEFAULT_GIT_DIR_ENVIRONMENT;
+ const char *git_dir;
va_list args;
unsigned len;
+ git_dir = gitenv(GIT_DIR_ENVIRONMENT);
+ if (!git_dir) git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
len = strlen(git_dir);
if (len > PATH_MAX-100)
return bad_path;
index e7bf83bb035f7613d0cb57ca3254e24141608382..ff550441e92339bd5c6fa70d8891ab208410a03e 100644 (file)
--- a/pull.c
+++ b/pull.c
//fprintf(stderr, "fetch %s\n", sha1_to_hex(obj->sha1));
- if (make_sure_we_have_it(obj->type ?: "object",
+ if (make_sure_we_have_it(obj->type ? obj->type : "object",
obj->sha1))
return -1;
if (!obj->type)
index bcb1c80d84b77e04bf843c2b38592284760ae165..04cbdf7a67e9f26d024da1117bf5a5a03596dd1b 100644 (file)
--- a/rsh.c
+++ b/rsh.c
return error("Couldn't create socket");
}
if (!fork()) {
- const char *ssh = getenv("GIT_SSH") ? : "ssh";
- const char *ssh_basename = strrchr(ssh, '/');
+ const char *ssh, *ssh_basename;
+ ssh = getenv("GIT_SSH");
+ if (!ssh) ssh = "ssh";
+ ssh_basename = strrchr(ssh, '/');
if (!ssh_basename)
ssh_basename = ssh;
else
diff --git a/sha1_file.c b/sha1_file.c
index 776697755a02b98c04fa7831077bd0205a1feb80..fa37f1e3ef97c7a35ec9eb4cd71ba7fda5e53055 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
char *map;
int fd;
struct stat st;
- char *alt = gitenv(ALTERNATE_DB_ENVIRONMENT) ? : "";
+ char *alt;
+
+ alt = gitenv(ALTERNATE_DB_ENVIRONMENT);
+ if (!alt) alt = "";
sprintf(path, "%s/info/alternates", get_object_directory());
if (alt_odb_tail)
diff --git a/ssh-pull.c b/ssh-pull.c
index b7f313bf277fc2f2c2cfb84048cd077728da9dd9..f1d8e706d3154fa1908a93d9b60936cb1a939557 100644 (file)
--- a/ssh-pull.c
+++ b/ssh-pull.c
char *commit_id;
char *url;
int arg = 1;
- const char *prog = getenv("GIT_SSH_PUSH") ? : "git-ssh-push";
+ const char *prog;
+
+ prog = getenv("GIT_SSH_PUSH");
+ if (!prog) prog = "git-ssh-push";
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
diff --git a/ssh-push.c b/ssh-push.c
index ee424a8712fad002f0a6962c3b7067fe25aed91a..5bd4569974c3c6851feb006a838fe69769388673 100644 (file)
--- a/ssh-push.c
+++ b/ssh-push.c
char *commit_id;
char *url;
int fd_in, fd_out;
- const char *prog = getenv("GIT_SSH_PULL") ? : "git-ssh-pull";
+ const char *prog;
unsigned char sha1[20];
char hex[41];
+ prog = getenv("GIT_SSH_PULL");
+ if (!prog) prog = "git-ssh-pull";
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 'w')
arg++;