Skip to contentSkip to conversation

sequencer: trivial cleanup

PATCH Superseded Ramkumar Ramachandra 3 participants 4 messages Jun 15, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sequencer: trivial cleanup

---
 sequencer.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
sequencer.c +1 -4
index 351548f..8ed9f98 100644
@@ -466,10 +466,7 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
 	empty_commit = is_original_commit_empty(commit);
 	if (empty_commit < 0)
 		return empty_commit;
-	if (!empty_commit)
-		return 0;
-	else
-		return 1;
+	return empty_commit ? 0 : 1;
 }
 
 static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
Signature · 1 line
1.8.4.100.gde18f6d.dirty
#1 lore raw
Quoted 10 lines · Ramkumar Ramachandra
---
 sequencer.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
sequencer.c +0 -0
index 351548f..8ed9f98 100644

sequencer.c static int allow_empty(struct replay_opts *opts, struct commit *commit) · line 470

Quoted 9 lines
sequencer.c +1 -4
@@ -466,10 +466,7 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
        empty_commit = is_original_commit_empty(commit);
        if (empty_commit < 0)
                return empty_commit;
-       if (!empty_commit)
-               return 0;
-       else
-               return 1;
+       return empty_commit ? 0 : 1;
 }

Isn't it the other way around? Moreover, 'return !!empty_commit;' would be simpler.

Signature · 1 line
Felipe Contreras
#2 lore raw

Hi,

Quoted 15 lines · Felipe Contreras
Quoted 14 lines · Ramkumar Ramachandra
---
 sequencer.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
sequencer.c +0 -1
index 351548f..8ed9f98 100644
@@ -466,10 +466,7 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
        empty_commit = is_original_commit_empty(commit);
        if (empty_commit < 0)
                return empty_commit;
-       if (!empty_commit)
Quoted 8 lines

sequencer.c static int allow_empty(struct replay_opts *opts, struct commit *commit) · line 470

Quoted 5 lines
sequencer.c +1 -3
-               return 0;
-       else
-               return 1;
+       return empty_commit ? 0 : 1;
 }

Isn't it the other way around? Moreover, 'return !!empty_commit;' would be simpler.

Considering the possible return values from is_original_commit_empty(), I think all this could be written as

  return is_original_commit_empty(commit);

Best,
Gábor

#3 lore raw
In reply to Felipe Contreras
Quoted 12 lines · Felipe Contreras
Quoted 12 lines
 sequencer.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
sequencer.c +0 -1
index 351548f..8ed9f98 100644
@@ -466,10 +466,7 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
        empty_commit = is_original_commit_empty(commit);
        if (empty_commit < 0)
                return empty_commit;
-       if (!empty_commit)
Quoted 8 lines

sequencer.c static int allow_empty(struct replay_opts *opts, struct commit *commit) · line 470

Quoted 5 lines
sequencer.c +1 -3
-               return 0;
-       else
-               return 1;
+       return empty_commit ? 0 : 1;
 }

Isn't it the other way around? Moreover, 'return !!empty_commit;' would be simpler.

Yeah, thanks for pointing out this grave stupidity. This seems to be inconsequential as far as the tests are concerned: have to do some major yak shaving.