@@ -72,11 +72,11 @@ static bool hash_in_history(const char* repo_root, const char* source_file, cons
7272 char history_path [PATH_MAX ];
7373 snprintf (history_path , sizeof (history_path ), "%s/.eb/history" , repo_root );
7474
75- fprintf ( stderr , "Debug - Checking history file: %s\n" , history_path );
75+ DEBUG_PRINT ( " Checking history file: %s\n" , history_path );
7676
7777 FILE * hist_file = fopen (history_path , "r" );
7878 if (!hist_file ) {
79- fprintf ( stderr , "Debug - Could not open history file\n" );
79+ DEBUG_PRINT ( " Could not open history file\n" );
8080 return false;
8181 }
8282
@@ -88,7 +88,7 @@ static bool hash_in_history(const char* repo_root, const char* source_file, cons
8888 if (* rel_source == '/' ) rel_source ++ ; // Skip leading slash
8989 }
9090
91- fprintf ( stderr , "Debug - Using relative source path: %s\n" , rel_source );
91+ DEBUG_PRINT ( " Using relative source path: %s\n" , rel_source );
9292
9393 char * matching_hash = NULL ;
9494 int match_count = 0 ;
@@ -100,12 +100,12 @@ static bool hash_in_history(const char* repo_root, const char* source_file, cons
100100 char hash_hist [65 ];
101101 line [strcspn (line , "\n" )] = 0 ;
102102
103- fprintf ( stderr , "Debug - Reading line: %s\n" , line );
103+ DEBUG_PRINT ( " Reading line: %s\n" , line );
104104
105105 if (sscanf (line , "%ld %s %s" , & timestamp , hash_hist , file_path_hist ) == 3 ) {
106- fprintf ( stderr , "Debug - Comparing paths - History: %s, Source: %s\n" ,
106+ DEBUG_PRINT ( " Comparing paths - History: %s, Source: %s\n" ,
107107 file_path_hist , rel_source );
108- fprintf ( stderr , "Debug - Comparing hashes - History: %s, Target: %s\n" ,
108+ DEBUG_PRINT ( " Comparing hashes - History: %s, Target: %s\n" ,
109109 hash_hist , hash_to_rollback );
110110
111111 if (strcmp (file_path_hist , rel_source ) == 0 &&
@@ -121,19 +121,19 @@ static bool hash_in_history(const char* repo_root, const char* source_file, cons
121121 fclose (hist_file );
122122
123123 if (match_count > 1 ) {
124- fprintf ( stderr , "Debug - Multiple matches found for hash prefix\n" );
124+ DEBUG_PRINT ( " Multiple matches found for hash prefix\n" );
125125 free (matching_hash );
126126 return false;
127127 } else if (match_count == 1 ) {
128- fprintf ( stderr , "Debug - Single match found: %s\n" , matching_hash );
128+ DEBUG_PRINT ( " Single match found: %s\n" , matching_hash );
129129 // Update the hash_to_rollback to the full hash for the index update
130130 strncpy ((char * )hash_to_rollback , matching_hash , 64 );
131131 ((char * )hash_to_rollback )[64 ] = '\0' ;
132132 free (matching_hash );
133133 return true;
134134 }
135135
136- fprintf ( stderr , "Debug - No matches found\n" );
136+ DEBUG_PRINT ( " No matches found\n" );
137137 return false;
138138}
139139
@@ -229,9 +229,8 @@ int cmd_rollback(int argc, char** argv)
229229 eb_status_t status ;
230230
231231 /* Debug output */
232- fprintf (stderr , "Debug - Rollback called with:\n" );
233- fprintf (stderr , " Hash: %s (length: %zu)\n" , hash_to_rollback , strlen (hash_to_rollback ));
234- fprintf (stderr , " Source: %s\n" , source_file );
232+ DEBUG_PRINT ("Rollback called with:\n Hash: %s (length: %zu)\n Source: %s\n" ,
233+ hash_to_rollback , strlen (hash_to_rollback ), source_file );
235234
236235 /* Basic hash format validation */
237236 size_t hash_len = strlen (hash_to_rollback );
@@ -260,7 +259,7 @@ int cmd_rollback(int argc, char** argv)
260259 abs_source_path [sizeof (abs_source_path ) - 1 ] = '\0' ;
261260 }
262261
263- fprintf ( stderr , "Debug - Using absolute source path: %s\n" , abs_source_path );
262+ DEBUG_PRINT ( " Using absolute source path: %s\n" , abs_source_path );
264263
265264 /* Check if hash exists in history for the source file */
266265 char full_hash [65 ];
0 commit comments